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
Mohit Kashyap 14Mohit Kashyap 14 

VR on Custom Object

We have a custom object "Business Scenario" which is a related list in Opportunity. If the Opportunity is closed won then we have to write the validation rule on the custom object in such a way that users are not able to edit this custom record once created only System Admin can edit this.
mukesh guptamukesh gupta
Hi Mohit,

Please use beloe validation formula
ISPICKVAL(Opportunity__r.StageName,'Closed Won') &&  $Profile.Name != 'System Administrator'

Enter Error message:
You are not able to edit this custom record once created only System Admin can edit this

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
Mohit Kashyap 14Mohit Kashyap 14
But Mukesh whenever I am logging in as user I am able to edit the custom records
mukesh guptamukesh gupta
Hi Mohit ,

Which profile user your are testing, Please let me know  and your validation rule should be activate.


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
AbhinavAbhinav (Salesforce Developers) 
Hi Mohit,

Did you tried adding isnew() condition as well with this validation?
 
gfdshbg grftdbggfdshbg grftdbg
I thin you need to try isnew() for better result I hope it will work beacuse they mentioned it for similar type of functions as you can see here (https://halifaxremovals.com/piano-removals-halifax/) I also done the similar one for my task.