Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
saraA

# IF LEN statemnent - can't pass syntax checker!

Hi -

I'm trying to create a formula (in a workflow)-

If the Length of field "Invoice Line Number" is 1,

make the field "Invoice_Number + "-0" + "Invoice Line Number" (add a zero to Invoice line number in front)

otherwise, just make the result "Invoice_Number + "-" + "Invoice Line Number"

My formula:

IF(LEN(TEXT(Invoice_Line_Number__c)),1, ("0"+ TEXT(Invoice_Line_Number__c)), (Invoice_Line_Number__c))

I keep getting Syntax errors, such as

Error: Incorrect parameter type for function 'IF()'. Expected Boolean, received Number

I have tried all sorts of changes, like putting the "1" in quotes, I have counted the parenthesis, and nothing is getting this right.

Thank you!!

Sara

JHayes SD

Hi Sara,

Try this:

`IF(LEN( TEXT( Invoice_Line_Number__c )) = 1,"0" + TEXT( Invoice_Line_Number__c ),TEXT( Invoice_Line_Number__c ))`

Regards, jh

JHayes SD

Hi Sara,

Try this:

`IF(LEN( TEXT( Invoice_Line_Number__c )) = 1,"0" + TEXT( Invoice_Line_Number__c ),TEXT( Invoice_Line_Number__c ))`

Regards, jh

This was selected as the best answer
JHayes SD

Edited my reply, some extra parens got inserted.

Hengky Ilawan

Hi,

The first parameter of the IF function is an expresssion that needs to be either True or False.

Try this:

```IF(
LEN(TEXT(Invoice_Line_Number__c)) = 1,
("0"+ TEXT(Invoice_Line_Number__c)),
(Invoice_Line_Number__c)
)```

Regards,

Hengky

saraA

Thanks! I must have had other errors when I tried the "=" sign - all set now.  Much appreciated

saraA

Thanks.  I like the line spacing/formatting you used, too. I have to get in that habit.