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
Ashok S 7Ashok S 7 

how can i slove the following trigger

Hai guys.
write a trigger on account object then trigger will evaluate the salary and will restrict to user to change the values.Use before update and compare trigger.old and

please help me to slove this requirment
srlawr uksrlawr uk
It sounds like the best place to start for that requirement would be the fun and easy learning tool "Trailhead" for Triggers..

This will give you the basic info on writing this trigger. Once you have these fundamentals down, your actual trigger is going to look something like this:
trigger restrictAccess on Account(before update) {

 for(Account thisAccount : {

    if(oldMap.get(thisAccount.Id).Salary__c < thisAccount.Salary__c) {
        // do some logic here to restrict value changes?



You haven't said what your evaluation/comparison is so I just stuck on in that will execute my commented line when the old salary is less than the new salary (ie the salary is going up).

That should get you going :)

don't forget your test coverage!!!!!!!!!
Ashok S 7Ashok S 7
but the following code is not working.
i will explain the requirment.
when a user comes to account object change the salary .the salary is not less than old value.
if the salary is less than old salary then restrict the user to enter the value.
srlawr uksrlawr uk
You didn't paste any "following code" in your last comment unfortunately.. :(

If you just want to stop people changing the Salary to a lower value - why don't you use a validation rule? Would be much, much simpler.

Chandra Sekhar CH N VChandra Sekhar CH N V
Yes, Validation rule is suggestable in this case. Try the below validation rule
PRIORVALUE( <your field>) >  <your field>