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

Adding a picklist value to global value set in test class

I am working on test class that inserts an Opportunity with the opportunity products using the correct price book/price book entry. The OpportunityLineItem has a ProductSelected__c picklist field. We recently implemented the Global value sets and this picklist is now using the active values from the Global value set. How do I do the following?

1) Create an opportunity (not a problem)

2) Create opportunity line items (not a problem)

3) How do I setup a new test value into the Global Value set and add the same into the ProductSelected__c picklist?

4) Apply the same ProductSelected__c value on the test Opportunity Line Item?

5) Also, we are not using the Standard Pricebook. Is there a way to get our custom pricebook in the test class code without using the SeeAllData = true option?

aliaa richardaliaa richard
You are doing a good job keep it up Very informative post (, thanks you so much for useful information.