I am creating a Formula field that returns texts when:
- Picklist_Status = Activated, the return text should be A else null
- Picklist_Status = Sold, the return should be B else null
- Picklist_Status = ChangeofMind , the return should be C else null
So these are 2 picklist fields that would update the formula field if a OR b OR C is true.
My FORMULA:
OR (
IF ( ISPICKVAL ( Status__c , 'Verified Complete' ), 'B' ,
IF ( ISPICKVAL ( OHSI_Status__c , 'Ok for Production' ), 'B+' ,
IF ( ISPICKVAL ( OHSI_Status__c , 'Activate' ), 'A'
'null' ))))
Error: Incorrect parameter type for function 'OR()'. Expected Boolean, received Text
I do not know where to put the OR.. these 3 should be OR
Best Answer
Editing this answer to reflect a better understanding of what you want to happen. I believe the ask is this:
As mentioned by Derek, formula fields don't update anything; they're calculated dynamically every time that they are viewed, but no data is stored internally. You can however simulate the above behavior with a formula field, essentially by reversing the order of your comparisons -- checking last to first.
Alternatively, if you want to actually store the data on the record, you can create a picklist field instead of a formula field, and give it three values, 'B', 'B+', 'A'. Then, create three workflow rules that run every time the record is updated to match the criteria for their related statuses, and then perform a field update to the new picklist, with the appropriate value. There are several benefits / considerations to using a real picklist instead of a formula, including,
Two final notes, last I checked, formulas should use double quotes when defining string literals (Apex is single quotes). Lastly, I used case statements for the picklists above, as I find them a bit more readable than chained IFs, especially with a lot of values. But that's personal preference; both will work.