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
Satheesh KumarSatheesh Kumar 

License Object Trigger not firing on "License Status" change


I am trying to write a trigger on the License object (sfLma__License__c) in my License Management org.. the purpose of this trigger to make a callout (in a future context) to my service to notify it of any new licenses or updates..
This is my trigger as of now
 
trigger MyLicenseTrigger on sfLma__License__c (after insert, after update) {

    for(sfLma__License__c newLicense: Trigger.newMap.values()) {
        LmoCalloutHelper.reportLicense(newLicense);
    }
}



Now if I update any editable field of this license from the UI (for eg. the Lead field) the trigger fires.. all good.


But if the managed package which is linked to the LMO is installed or uninstalled, the trigger does NOT fire.
On digging a bit, I see that on install/uninstall, the License Status is changed. But License Status is a formula field which obviously doesnt fire triggers.


But the formula field is just a $recordType.Name, so basically it seems any install/uninstall updates the Record Type of a license record.
So on install/uninstall of a package, if the Record Type is updated, why does my trigger not fire?

Shri RajShri Raj

The trigger you've written is only set to fire after insert and after update events. Since the License Status field is a formula field, it does not actually get updated in the database when the package is installed or uninstalled. Instead, the record type of the license record is updated, which does not trigger your trigger. To handle this scenario, you can either update your trigger to also fire on before update events, or you can update your code in the trigger to check if the record type has changed and call the LmoCalloutHelper.reportLicense method accordingly.
Satheesh KumarSatheesh Kumar

Thank you for the respons. 

I know formula fields do not fire triggers. 

But can you point to any Salesforce documentation which mentions RecordType change does not fire triggers? 

 

 

 

To handle this scenario, you can either update your trigger to also fire on before update events, or you can update your code in the trigger to check if the record type has changed and call the LmoCalloutHelper.reportLicense method accordingly.
 

If the trigger itself does not fire for record type changes like you mentioned, how will this help?