We want to run some logic on Account trigger only if it is created/updated via lead conversion.

So far, we have tried 2 approaches:

Approach 1: We tried creating a checkbox field on Account 'Is Lead Converted' and map it with a custom field on Lead object having default value as true. Above approach works fine for new Account but doesn't work for existing because checkbox field does not updates to true.

Approach 2: We also tried to create a text field and map it with a lead text field having default value as 'true' instead of Checkbox field. This worked and value updates from null to 'true'. Since we have to update the default value in the existing leads, we couldn't proceed with this approach because of some other restriction with respect to existing data in the org.

Is there any other approach to solve this issue.

1 Answer 1


You can use the account's LastModifiedDate and the lead's ConvertedDate. This achieves roughly what you want by checking if the dates are the same. Ideally, you want a DateTime but that field is not available by default. Maybe you can do something with an immediate update rule on lead conversion to set a DateTime field and check if the account is updated within a certain time window.

trigger AccountTrigger on Account (after update) {
    // Fetch all the converted leads with a ConvertedAccountId from today
    List<Lead> convertedLeads = [SELECT Id, ConvertedAccountId 
                                 FROM Lead 
                                 WHERE isConverted = TRUE 
                                 AND ConvertedAccountId != NULL 
                                 AND ConvertedDate = TODAY];

    // Create a set of ConvertedAccountId
    Set<Id> accountIdSet = new Set<Id>();
    for (Lead leadObj : convertedLeads) {

    // Loop through the Accounts and check if their ID is in the set
    for (Account acc : Trigger.new) {
        if (accountIdSet.contains(acc.Id)) {
            // Your logic for the accounts that match the criteria

Hope this gets you started.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .