After running this...

curl -X PATCH "https://custom.my.salesforce.com/services/data/v56.0/sobjects/Opportunity/0060900000OWbmEAAT" \
  --header 'Authorization: Bearer INTENTIONALLY_REMOVED' \
  --header 'X-PrettyPrint:1' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"StageName":"INVALID"}'

It succeeds and sets the Opportunity.StageName to "INVALID" on the Opportunity Lightning Record Page...

enter image description here

...and adds INVALID to the list of Inactive picklist values:

enter image description here

Is there a way to get an error when I try to patch a picklist field with an invalid value?

While I can get the results of a query like SELECT MasterLabel FROM OpportunityStage first to validate the new StageName is there, this would be slower.

I guess this issue is about Opportunity.StageName being an unrestricted picklist when I want it to behave like a restricted one. Is there a way to change that without creating a custom picklist that stands in for Stage?

  • Please edit the question to explain what actually happens - and cover what the picklist field definition looks like (you may have an unrestricted picklist, in which case new entries get added when you provide an unrecognised value).
    – Phil W
    Commented Jan 2, 2023 at 18:31
  • Thanks - just updated the question to make it more explicit. Is there a way to make a built-in picklist like Stage restricted? Commented Jan 2, 2023 at 19:38
  • 2
    I think you need to put a validation rule rule in place to only allow specific values. You can also upvote this idea.
    – Phil W
    Commented Jan 2, 2023 at 21:04


You must log in to answer this question.

Browse other questions tagged .