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
Sonu06Sonu06 

how to bypass trigger when we insert record through data loader

how to bypass trigger when we insert record through data loader
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sonal,

Greetings to you!

There's an idea which is active on the success community with a similar discussion for which you can upvote so that it gets available in the future.

https://success.salesforce.com/ideaView?id=08730000000l75PAAQ

https://success.salesforce.com/ideaview?id=087300000007CwUAAU

However, there are a few workarounds which you can try. Please refer to the below links which might help you further.

http://www.salesforcegeneral.com/salesforce-articles/salesforce-bypass-rules-and-triggers.html

https://learnsf.wordpress.com/2011/05/21/disable-validation-rules-4-data-load/

http://www.infallibletechie.com/2018/10/how-to-bypass-all-triggers-validation.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
prashant rishi 6prashant rishi 6
Hi Sonal, 
What u can do is create metadata record in which u can add the check box of disable the trigger and 
in trigger logic u will only fire when that flag is set to false
Some like : if(!flag){
Fire Trigger
}

By doing so u can handle it only by configurational change just update the checkbox and then try for import of records.
Arun Kumar 1141Arun Kumar 1141

Hi Sonu06,

To bypass triggers when inserting records through Data Loader in Salesforce, you can use a technique involving a custom field. By following these steps, you can accomplish the desired outcome:

1. Create a custom field on the object for which you want to bypass the trigger. This field will act as a flag to indicate whether the trigger should be skipped during the insert operation.

2. Modify your trigger code to include a check for the custom field's value. Before executing any logic in the trigger, evaluate the value of this field. If the flag indicates that the trigger should be bypassed, you can simply exit the trigger without further execution.

3. Prior to performing the insert operation through Data Loader, mak sure that you map the custom field with a specific value (e.g., true) for all the records being inserted. This will trigger the condition in your trigger code and effectively bypass the execution.

By implementing this approach, you can selectively bypass triggers during insert operations via Data Loader, while allowing the triggers to function as usual in other scenarios.

Remember to communicate and document this bypass mechanism within your team to maintain clarity and consistency in your development practices. It is necessary to thoroughly test your solution in a non-production environment to ensure that it works as expected and aligns with your specific requirements.

Please note that bypassing triggers should be done with caution, as triggers often enforce critical business logic and data integrity. Make sure to fully understand the implications and conduct comprehensive testing before applying this solution in a production environment.