IF Statement with Condition Outside of Data Context, Multiple Conditions

We have a customer who needs a charge on the SO Invoice to read as a specific phrase. The logic is this: If the InvoiceAccount is 000300 and the Description is “Insurance Upcharge”, then put “Documentation Fee”.

I have attempted this with many variations using a nested iif() statement on the OILMarkupTotalsTmp/@Description Field tag, and also using and AND within the condition object of a single iif() statement. I am not able to achieve the desired result. I am able to change the text if I leave out the condition of the InvoiceAccount. I am using the Data Context for a Group tag on the OILMarkupTotalsTmp node. Below is a sample of my attempt.

iif(SalesInvoiceHeaderFooterTmp/@InvoiceAccount = “000300”,
iif(OILMarkupTotalsTmp/@Description = “Insurance Upcharge”,
“Documentation Fee”),

Hi @AOCUSA_Baaron,

Try this Xpath expression instead:

iif(SalesInvoiceHeaderFooterTmp/@InvoiceAccount = ‘000300’
OILMarkupTotalsTmp/@Description = ‘Insurance Upcharge’ ,
‘Documentation Fee’,

  • It checks if the invoice account number is a specific code (like ‘000300’).
  • It also checks if a charge is for “Insurance Upcharge”.

If both conditions are true, it changes to the “Documentation Fee”. Otherwise it will use Description.

If this doesn’t work, send your template to support email so I can examine it. It’s possible that some field merging isn’t correct.

Thank you Amir. I had actually tried that statement before posting and it did not work. I tried it again with a copy/paste of your statement for thoroughness, but without success. I have always reached out to support via email and you all are very responsive. I decided to begin using the forum so others can benefit from the help I receive. I will update this post after support email resolution.

Hi @AOCUSA_Baaron,

We encourage our users to use our forum for the exact reasons you mentioned. By sharing your case, other users can benefit as well. Remember, sharing is caring.:blush:

I didn’t notice your email in our support inbox. Could you confirm if you’ve sent it?

I have submitted the request for help to Support. Sorry for the delay.

Hi @AOCUSA_Baaron,

I will post the answer I have already sent to you via the support ticket that you’ve opened. This way we can share the solution with the whole community.

The logic you have implemented is correct, there is just one small thing you have missed. Since the List tagging element is binded to a OILMarkupTotalsTmp lines this makes the @Description field its child element, but this is not the case for @InvoiceAccount field.
That is why, you need to reference the whole path of the @InvoiceAccount field. This field is located in the SalesInvoiceHeaderFooterTmp lines. To reach this record, cursor must go into parent element, which is ReportData and then into the SalesInvoiceHeaderFooterTmp lines, where the @InvoiceAmount is located.

You can go into the parent element by using the following operator:


The expression has therefore been missing just the path to the @InvoiceAmount field, so that it would look like this:

iif(../SalesInvoiceHeaderFooterTmp/@InvoiceAccount = '000300' and @Description = 'Insurance Upcharge','Documentation Fee',@Description)