0

I have created a formula in process builder that when evaluated to True, should create a task.

Properties: When a record is created or edited Formula evaluates to true

Immediate Action: Create a Record

Conditions are as follows :

When Contact Owner changes AND Contact Owner IS NOT 'a particular id', Contact.AccountId ! = null AND Contact.Account.Status = 'Active' AND Contact.AccountRecordType = 'Supplier Account' AND Contact.Account.ShippingCountry = 'a particular country' AND Contact.AccountOwner.Profile = 'A particular profile' AND Contact.email ! = null

If ALL Conditions are satisfied, create a task for the Account Owner

enter image description here

enter image description here

enter image description here

Formula

AND(
 ISCHANGED([Contact].OwnerId),
 ([Contact].OwnerId) != '005XXXXXXXXXXXXXXXXX',
 [Contact].Owner.Profile.Name  = 'System Admin',
 NOT(ISNULL([Contact].AccountId)),
 [Contact].Account.RecordType.DeveloperName = 'Supplier_Account',
 NOT(ISBLANK([Contact].Email)),
 ([Contact].Account.ShippingCountry = 'Canada' || 
 [Contact].Account.ShippingCountry = 'CA'),
 ISPICKVAL([Contact].Account.Status__c, "Active")
)

EDIT: 1/25/2020 12:48 pm I edited the formula as follows my problem seems to be resolved, i.e the tasks are created. However I fail to understand why the original formula doesn't work. When I remove ISChanged and PriorValue the formula works. Would it be, that an existing trigger is firing twice, before process builder kicks in.?

AND(
([Contact].Account.OwnerId) != '005E0000008HCucIAG',
([Contact].Account.Owner.Profile.Name )  = 'Sales',
NOT(ISNULL([Contact].AccountId)),
([Contact].Account.RecordType.DeveloperName) = 'Dealer_Account',
NOT(ISBLANK([Contact].Email)),
([Contact].Account.ShippingCountry = 'Canada' || 
[Contact].Account.ShippingCountry = 'CA'),
ISPICKVAL([Contact].Account.Dealer_Status__c, "Active")
)
4
  • So what's the question here? Is it not working or are you looking to edit your current formula to match the conditions you mention in the beginning of your post? Jan 25 '20 at 17:22
  • It is not working. i.e not creating tasks. However i edited the formula and now it works. However I fail to understand why it did not work with the orginal formula. Jan 25 '20 at 17:48
  • It depends on how you're testing and what other automation you have. Are you changing the ownerID on an existing contact where the other conditions are met? Or are you testing as creating a new contact? Jan 25 '20 at 18:28
  • Yes to both of your questions. When a new contact is created, as well as when the Owner on an existing Contact is updated. The other Automation I have is this - Trigger on Contact - When Account Owner Changes, make Contact owner same as Account Owner. Trigger of Account - When Contact Owner changes, make Account Owner same as the Contact Owner. I think this is causing the problem - both triggers firing recursively, and as a result, I always see the new value of the Owner, without a trace of old value. Jan 26 '20 at 16:07
0

Yes, both triggers are running recursively, due to which you are not able to track any old value. Also, you can put recursive check in triggers, This will improve performance of system and you will see less delay in running your functionality. Instead of running those every time, put a check with a Boolean variable as below

Apex class


    private static boolean checkTriggerRun = true;
    public static boolean runOnce(){
    if(checkTriggerRun){
     checkTriggerRun=false;
     return true;
    }else{
        return checkTriggerRun;
 }
    }
}

Trigger

trigger updateTrigger on anyObject(after update) {

    if(checkRecursive.runOnce()){
    //write your code here            
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.