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
Katherine RoweKatherine Rowe 

Trigger for records only

I am writing a trigger for Accounts that I only want to run when the Account is created via, as opposed to: the user through the GUI, the user through API.

How can I write my trigger to detect whether the account is coming from or not? Is there a "best practice" way of doing this?

Hi Katherine,

On the user record, you have a boolean field API named UserPermissionsJigsawProspectingUser which if the only indicator on whether the user is allocated a user license (value is TRUE) or not (value is FALSE). The user license lets the user add contact and lead records to Salesforce in the supported editions.

I hope this answers your question; please do let me know how it works out for you.

If you feel that your question was answered then do flag the answer as the solution to your query.

Kind Regards,

Katherine RoweKatherine Rowe


But if the user has a license but is creating an account manually... then I don't want the trigger to run. I think if I simply use "UserPermissionsJigsawProspectingUser" then it would run for manually created accounts as well?

What about the field " Key" (api name is "Jigsaw"), I could use that, right?

Katherine RoweKatherine Rowe
And what about updates (which would be clean, not prospector. How can I make my trigger distinguish between an account from (1) that is being updated by through Clean, and (2) that is being updated manually, through the API, a workflow rule, etc.