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
shimy josshimy jos 

When a new Invoice is created, validate if the associated Opportunity has a status ‘open’ using validation rule?

whenever an invoice(Invoice__c is the custom object) is created ,the opportunity status must change to open .How can i do using validation rule?
Best Answer chosen by shimy jos
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Shimy,

Can you try the below validation rule as you said in the question the validation should fire only when created so included isnew().
 
AND(ISNEW(),Text(Opportunity__r.Status__c) <>'Open')

Thanks,
​​​​​​​

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Shimy,

Can you confirm which is if opportunity is parent object and also this valiudation rule should fire only on create scenerio right?

Thanks,
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Shimy,

Can you try the below validation rule as you said in the question the validation should fire only when created so included isnew().
 
AND(ISNEW(),Text(Opportunity__r.Status__c) <>'Open')

Thanks,
​​​​​​​
This was selected as the best answer
shimy josshimy jos
Hi Sai praveen,

Thank you so much for the reponse and it worked.