in Education by
Is there a way to determine if a trigger is being executed by an API call or through the Salesforce Web Interface? I'd like to do something like this: trigger Update_Last_Modified_By_API on My_Object__c (before update) { for (My_Object__c o : Trigger.New) { if (isAPI) { o.Last_Modified_By_API__c = datetime.now(); } } } (Currently using API version 25.0, though will soon be updating to 26.0) Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
There is no conventional way to in a trigger which can tell what actually might have caused an insert or update to happen. But, to achieve this, you can create a custom checkbox field on the object, something like IsAPI_c. After which you need to pass in true for that field with any API call and then check the field in your trigger for each record in the batch. trigger Update_Last_Modified_By_API on My_Object__c (before update) { for ( My_Object__c o : Trigger.New ) { if ( o.IsAPI__c ) { o.Last_Modified_By_API__c = datetime.now(); } o.IsAPI__c = false; } }

Related questions

0 votes
    I have recently discovered that salesforce.com is much more than an online CRM after coming across a Morrison's Case ... ' .Net route? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Is there any way to check if a list contains a certain element? I looked at the List functions and did not see any ... ; } break; } } Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    The Salesforce.com API seems to assume that you will always use the app as an active user. Their ... require user interaction? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    The Salesforce.com API seems to assume that you will always use the app as an active user. Their ... require user interaction? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    Friends, I have a contact us/Inquiry form in my website. I want to generate a lead in Sales force CRM on ... any link for API. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to update a record via the SalesForce API (Enterprise WSDL). The code below executes fine, and the ... updateParticipant }); if (result == null || result.Length...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    How do I make a SOQL query like this? SELECT id FROM Account WHERE LastActivityDate = 30_DAYS_AGO This produces an ... = 30_DAYS_AGO ^ Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I would really appreciate if someone can guide me to check if a particular field is included in update call inside ... . Many thanks. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a web service class that will be in a managed package and distributed to multiple clients. The class ... accomplish this? Thanks Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Salesforce Einstein is considered to be the __________. A. Visualizer B. Personal Calculator C. Personal Data Scientist...
asked Nov 1, 2022 in Education by JackTerrance
0 votes
    I wanted to map custom fields of lead to map with custom field of contact' when converted using binding.convertLead ... should be made Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a page with a form that posts to salesforce.com's webto Lead service. I am trying to make an ... receiving website can see? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a page with a form that posts to salesforce.com's webto Lead service. I am trying to make an ... receiving website can see? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    Is there a library or package which we can use with python to connect to salesforce and get data? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I would like to integrate SalesForce information into a .net MVC application. The samples on SalesForce website are ... .NET Thanks. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
...