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
ColinKenworthy2ColinKenworthy2 

Is there any way to tell if my trigger is being run because of Dataloader ?

I can only think of setting up a new user for data loader jobs and testing for that user in the Userinfo class?

 

Can anyone think of another way?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

The only other way I've come up with is to have a field that only the dataloader populates (hidden from other page layouts etc).  Then your trigger can check if that field is null and if not, know it was the dataloader.

All Answers

bob_buzzardbob_buzzard

The only other way I've come up with is to have a field that only the dataloader populates (hidden from other page layouts etc).  Then your trigger can check if that field is null and if not, know it was the dataloader.

This was selected as the best answer
ColinKenworthy2ColinKenworthy2

If it isn't on any page layouts do I run the risk of getting any 'Field referenced but not retrieved in SOQL' errors.

Also I think I'd need to blank out the value so regular screen updates don't throw that value back into tthe trigger later on?

bob_buzzardbob_buzzard

I wouldn't expect page layouts to have that issue - that tends to around FLS from what I remember.

 

Yes, normally the final act of my trigger is to clear down the field.