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
KenBarlowKenBarlow 

SOQL Query all cases in an org to see if a value exists?

Is there a way to query all cases in an org using SOQL to see if there is a case with a specific order number particular to our business that has been submitted already?
TylerBrooksTylerBrooks
Ken,

Try the below query:

[Select Id, CaseNumber, Order_Number_Field__c from Case Where Order_Number_Field__c = value]

That should query all cases in your org and then just replace Order_Number_Field__c with the API name of your field and then replace value with the value you're looking for and it will return any records that meet that criteria. Or return no records if it doesn't exist.

Regards, 

Tyler