function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DX-NoobDX-Noob 

Help using ISPICKVAL to populate a number field

Looking for help trying to figure out this error.  We are creating a points system based on the number of times something is published.  I'm trying to create a formula that will enter a specific number into number field after the prospect becomes a customer.  I've already created the workflow, I just having some trouble with the formula to generate the number.  The number field needs to be editable so that it can be overridden by the sales manager.  It also needs to be a number so that we can use it in reporting calculations.  

 

Here's the formula I am trying to work with for the field update:

IF(ISPICKVAL (Publishing_Schedule__c = "Weekly"),"1",IF(ISPICKVAL(Publishing_Schedule__c = "Daily"),"7",IF(ISPICKVAL(Publishing_Schedule__c = "Monthly"),"0.25",IF(ISPICKVAL(Publishing_Schedule__c = "Biweekly"),"0.50",IF(ISPICKVAL(Publishing_Schedule__c = "Semiweekly"),"2")))))

 

The error I receive is:  Error: Field Publishing_Schedule__c is a picklist field. Picklist fields are only supported in certain functions.

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

What is the datatype of your Formula Field? If it's a Formula(Number) then you have to remove the quotes from around the number in your formula.   

Also your formula is missing an Else Result.  

If you're evaluating the same Picklist field multiple time you're better off using a CASE function like this:

 

CASE(Publishing_Schedule__c, 
"Weekly", 1,
"Daily", 7,
"Monthly", 0.25,
"Biweekly", 0.50,
"Semiweekly", 2,
NULL)

 

 

All Answers

Steve :-/Steve :-/

What is the datatype of your Formula Field? If it's a Formula(Number) then you have to remove the quotes from around the number in your formula.   

Also your formula is missing an Else Result.  

If you're evaluating the same Picklist field multiple time you're better off using a CASE function like this:

 

CASE(Publishing_Schedule__c, 
"Weekly", 1,
"Daily", 7,
"Monthly", 0.25,
"Biweekly", 0.50,
"Semiweekly", 2,
NULL)

 

 

This was selected as the best answer
DX-NoobDX-Noob

Thanks, it worked like a champ.  I haven't really used CASE all that often, but it makes sense in this scenario.