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
Ana RottaroAna Rottaro 

validation rule on create only causing problems on edit

I have the following validation rule and I want it to only prevent creation of new opportunities if one already exists and is open (what Count of Opportunities is counting). However, I had an account executive unable to Close Won an existing Opportunity which is the only opp on the account because of it.  

AND(
Account.Count_of_Opportunities__c>0,
$User.Title == "Account Executive",
isnew()
)
Best Answer chosen by Ana Rottaro
SarvaniSarvani
Hi Ana,

The formula looks good and it should work as expected only preventing to create new opps if there is atleast one opportunity existing on the account. (I tested in my org with same and its wokring fine).

Please verify if there are any other similar validation rules on opportunities preventing user to edit. Also cross verify if the error message on the record is matching with your current validation rule error message.

Hope this helps!

Thanks

All Answers

SarvaniSarvani
Hi Ana,

The formula looks good and it should work as expected only preventing to create new opps if there is atleast one opportunity existing on the account. (I tested in my org with same and its wokring fine).

Please verify if there are any other similar validation rules on opportunities preventing user to edit. Also cross verify if the error message on the record is matching with your current validation rule error message.

Hope this helps!

Thanks
This was selected as the best answer
Ana RottaroAna Rottaro
Hi Sarvani,

Thanks for your response! I just realized it is because we have a trigger that creates a renewal opportunity when the new business opportunity is closed won.  What was happening was the person editing the opportunity was trying to edit the existing opportunity to close won and it would fail because a new opportunity was being created.  I guess the order of events made it out to be that the roll up of opportunities would briefly move to 2.  I resolved this by adding a part to the validation rule where it only runs for new business opportunities. 

Thanks for letting me know it would have run otherwise!
kaushal sharma 33kaushal sharma 33
sarkari result (https://sarkarifoam.com)