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
SupriyaH9SupriyaH9 

How to make a trigger NOT RUN on manual changes?

So, I have 2 fields Current Term and Next Term (which are lookups to another custom object called Term) on a custom object. There is a before update trigger that auto-populates Next Term as soon as the Current Term is filled. Everything is fine until this point. Now, the new modification that I need to make is if Next Term is filled in manually, the logic of updating Next Term based on the Current Term SHOULD NOT run. Also, standard page-layout is being used for this object. 
Any ideas?
RaidanRaidan
You will have to modify the trigger to check if the Next Term is not blank, then populate the value.
 
if(String.isBlank(Next_Term__c)) {
   //execute the current logic to populate based on the current term
}

 
VineetKumarVineetKumar
How else is the Next Term populated apart from doing it manually (is there any VF page or something)?
Perhaps you may want to look that this particular context variable for Trigger.
isExecuting - Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call.

Make your code run conditionally by checking this condition.
Maybe you can tell me something more about the way the records are update.

Let me know if it helped.
Do mark it as a best answer if it did.