Defining Salesforce Triggers on Infer Scores

In some cases, it may be useful to define a Salesforce Trigger that fires when an Infer Score is written or updated, such as part of routing Leads that score over a certain threshold. However, it is important to note that Infer does not write scores directly to Lead or other standard objects, but rather to a custom Score object. (The Infer Score on the standard object is a formula field that references the Score object.) This means that the trigger should refer to the Score object not the Lead or other standard object directly.

Here is an example of a trigger that fires when a Lead gets a new score.


trigger updateLead on Infer_Entity_Score__c (after update) {

List leadIds = new List();

for (Infer_Entity_Score__c score : {

if (score.Entity_Type__c == 'lead') {




if (leadIds.size() == 0) {



Lead[] leads = [

SELECT Id, Owner FROM Lead WHERE Id in :leadIds


for (Lead lead : leads) {

// update lead owner

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk