+ Start a Discussion
Jacek DJacek D 

Custom If Statement Failure

Hi,

 

I receive the following error on my formula: Error: Incorrect parameter for function 'If()'. Expected Text, received Boolean

 

Any suggestions why?

 

Thanks!

 

If ( OR (  Delete_Flight__c = true ,  Campaign_2__r.Delete_Flights__c = true ) , "Delete" ,

If ( Export_Confirmation_Result__c == "Insert - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Insert - Fail" , Needs_review__c == True ,

If ( OR (  LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.Contract__r.LastModifiedDate >  DateTime_Sent__c ) , "Update" ,

If ( Export_Confirmation_Result__c == "Update - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Update - Fail" , Needs_review__c == True ,

If ( Export_Confirmation_Result__c == "Delete - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Delete - Fail" , Needs_review__c == true ,

null ))))))))

 

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Your formula seems to have return type TEXT . And some places its returing boolean value like if 

 

If ( Export_Confirmation_Result__c == "Insert - Fail" is one where is this condition will satisfy you will return boolean

value Needs_review__c == True

 

 

But if you look at your formula

 

If ( OR (  Delete_Flight__c = true ,  Campaign_2__r.Delete_Flights__c = true ) , "Delete" ,

If ( Export_Confirmation_Result__c == "Insert - Success" , "None" ,

 

If ( Export_Confirmation_Result__c == "Insert - Fail" , Needs_review__c == True ,

 

If ( OR (  LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.Contract__r.LastModifiedDate >  DateTime_Sent__c ) , "Update" ,
If ( Export_Confirmation_Result__c == "Update - Success" , "None" ,
If ( Export_Confirmation_Result__c == "Update - Fail" , Needs_review__c == True ,
If ( Export_Confirmation_Result__c == "Delete - Success" , "None" ,
If ( Export_Confirmation_Result__c == "Delete - Fail" , Needs_review__c == true ,
null ))))))))

 

Please make sure every part of your formula only returns the return data type for formula.

All Answers

SteveMo__cSteveMo__c

What are the datatypes of each field that you're evaluating in your Formula?

Jacek DJacek D

It's a field update formula that populates a text field with the true values "Delete", "Update" etc.

 

The datatypes of the fields to evaluate vary depending on each statement in this order: checkbox, text field, text field, DateTime, and 4x text field.

 

When checking the syntax, Salesforce tells me the error and marks the last if-statement only.

Shashikant SharmaShashikant Sharma

Your formula seems to have return type TEXT . And some places its returing boolean value like if 

 

If ( Export_Confirmation_Result__c == "Insert - Fail" is one where is this condition will satisfy you will return boolean

value Needs_review__c == True

 

 

But if you look at your formula

 

If ( OR (  Delete_Flight__c = true ,  Campaign_2__r.Delete_Flights__c = true ) , "Delete" ,

If ( Export_Confirmation_Result__c == "Insert - Success" , "None" ,

 

If ( Export_Confirmation_Result__c == "Insert - Fail" , Needs_review__c == True ,

 

If ( OR (  LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.Contract__r.LastModifiedDate >  DateTime_Sent__c ) , "Update" ,
If ( Export_Confirmation_Result__c == "Update - Success" , "None" ,
If ( Export_Confirmation_Result__c == "Update - Fail" , Needs_review__c == True ,
If ( Export_Confirmation_Result__c == "Delete - Success" , "None" ,
If ( Export_Confirmation_Result__c == "Delete - Fail" , Needs_review__c == true ,
null ))))))))

 

Please make sure every part of your formula only returns the return data type for formula.

This was selected as the best answer
Jacek DJacek D

Ah, thanks a lot! That makes sense.

 

I was hoping I would be able to address different data types within a single formula.

 

So in order to update a checkbox, I would need to create another field update formula?!