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
Mathieu Guay-GallantMathieu Guay-Gallant 

Picklist fields are only supported in certain functions.

Hi,

I am trying to build a formula field (number) to track to number of opportunities of a certain type that contain a certain product. I have a field called "Type of Sale" (picklist) that we use to track the type of sales we make (Serialization, Serialization and aggregation, Inspection, etc). I want to create a field that will look at that field and if it has a certain value (Serialization OR Serialization and aggregation) AND a certain product (BottleTracker OR CartonTracker OR Flying CartonTracker OR Manual Print Station OR PackStation CAP OR PacStation SAP OR PackStation SAP OR LabelTracker OR BunderTracker) is attached to the opportunity, the field value will be 1. If not, it will be 0. I will then use that field to report of the % of Serialization AND Serialization and aggregation sales that include the aforementioned products.

I have came up with the following formula:

IF(AND(OR(Type_of_Sale__c="Serialization", Type_of_Sale__C="Serialization and aggreation"), (OR(PricebookEntry.Product2.Name="BottleTracker", PricebookEntry.Product2.Name="CartonTracker", PricebookEntry.Product2.Name="Manual Print Station", PricebookEntry.Product2.Name="PackStation CAP", PricebookEntry.Product2.Name="PackStation FMP", PricebookEntry.Product2.Name="PackStation SAP", PricebookEntry.Product2.Name="BundleTracker", PricebookEntry.Product2.Name="LabelTracker")), 1, 0))

When I use the "check syntax" button, the syntax is fine, but it tells me that "Picklist fields are only supported in certain functions".

How should I proceed to achieve my goal? I have absolutely no experience with advanced formulas so please dumb it down to my level.
Best Answer chosen by Mathieu Guay-Gallant
Brian Oconnell 23Brian Oconnell 23
Try using replacing Type_of_Sale__c with TEXT(Type_of_Sale__c) to convert the picklist value into a text value, which can then be compared to the text literal.

All Answers

Brian Oconnell 23Brian Oconnell 23
Try using replacing Type_of_Sale__c with TEXT(Type_of_Sale__c) to convert the picklist value into a text value, which can then be compared to the text literal.
This was selected as the best answer
Mathieu Guay-GallantMathieu Guay-Gallant
Thank you very much Brian, it worked.

I however had to move my new field to the Opportunity Product object in order for it to work. It doesn't affect my capacity to report on it so that is perfect.

Once again, thank you very much for your MUCH appreciated help.

Have a nice day,

Matt
manibharathi vmanibharathi v
public class oppicktriggerhandler {
    public static void ispick(list<opportunity> picval){
        for(opportunity test:picval){
              if(test.revenue_type__c <>'renewel&expansion'){
                  if(test.revenue_type__c <>'renewel'){
                   //test.adderror(test.competitor__c=null);
                     test.competitor__c.addError('competitor field is mandatory');
                       test.lost_reason__c .addError('lost reson field is mandatory');
                  }
            }            
        }
        
    }
}
write the trigger for it