Function 'iif()' has failed

Hi support,

This is probably something small I’m just not seeing, can you help please?

2001 project invoice.docx (99.5 KB)
WLPPMIPPSAProjInvoice.PMIPProjectInvoicing (14).ddsp (173.3 KB)

Hi Nicky,

I am not sure if I understand what do you want to achieve.

Do you maybe want to implement the following logic:

If the invoice number starts with PTIN and total < 0 then the title is “Credit Note”,
otherwise if invoice number starts with PTIN and total > 0 then the title is “Proforma”,
otherwise keep the original title.

Hi ALbin,
Apologies, I should have explained in my original post.

We’re using the same template for both proforma and posted invoices. The Proforma invoice will start with a P_, a posted tax invoice will start with PTIN and a posted credit note with PCRN. I need the conditions set to display each of the names based on what the Invoice number starts with (I just realized this is an easier way than to use the Total value).
Still not getting it right though:

Hi @Nicky,

The expression you’ve written seem correct. I believe the only issue is that the Invoice string wasn’t put in single quotes like so: 'Invoice'

The whole expression should look like this:

iif(starts-with(PMIPPSAProjInvoiceHeaderTmp/@InvoiceNum, 'PTIN'), 'Tax Invoice',
iif(starts-with(PMIPPSAProjInvoiceHeaderTmp/@InvoiceNum, 'PCRN'), 'Credit Note',
iif(starts-with(PMIPPSAProjInvoiceHeaderTmp/@InvoiceNum, 'P_'), 'Proforma', 'Invoice')))

Can you confirm that this works?

It works. :slight_smile: Thank you.

1 Like