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
Jennifer HarrisJennifer Harris 

Workflow Rule Triggers Two Different Rules

I have 2 time based workflows that should send an email anytime a Contract Expiration Date is 90 days away. One workflow rule is based on sending to an email to the East and one is based on sending an email to the West. I cannot figure out why they are both triggering an email when I create a new record. Can you spot what is triggering both to fire off in my workflows?

Workflow 1 West
AND(NOT( ISBLANK( Contract_Exp_Date__c)), 
OR( 
AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "W"), 
AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect", CONTAINS(AccountId__r.Owner.User_Region__c, "WESTERN"))))

Workflow 2 East
AND(NOT( ISBLANK( Contract_Exp_Date__c)), 
OR( 
AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
AND( AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect"), CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN")))

Additional information- the Evaluation Criteria: Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria

I appreciate any help that is given!
Best Answer chosen by Jennifer Harris
Leslie  KismartoniLeslie Kismartoni
Sorry, mistook the way it was structured... 

After a bit of formatting, the original formula for East is 
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect"), 
        CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN")
    )
)

Given what you said in your response, I think it should be (East):
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect", CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN"))
    )
)

(West)
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "W"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect", CONTAINS(AccountId__r.Owner.User_Region__c, "WESTERN"))
    )
)

I think you split up the
AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect"),
so that it didn't include the condition that the User Region also had to be specific... In that case, both workflows seem to fire because the above statement is true and the OR returns a true value (it disregards the Region...) 

Lemme know if this works... 
 

All Answers

Leslie  KismartoniLeslie Kismartoni
I think in your code, the OR operator will evaluate to true in both the East and West cases since both cases test for the following which should evaluate to true. 
AND( AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect")
(Check out how the OR function works here (https://help.salesforce.com/apex/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US#OR" target="_blank) - SFC doc page)


Maybe rewriting the forumla to something like (for the Eastern case - though I didn't try this...)
 
AND(
    AND(NOT( ISBLANK( Contract_Exp_Date__c)), 
        AND( AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect")
    ), 

    OR( AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
        CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN")
    )
)

 
Jennifer HarrisJennifer Harris
No dice on this one. Thank you so much Leslie for your input! I switched the formula around a bit to make sure it is capturing the criteria it needs to, but it is still not working. 

For Eastern (or Western just input W and Western for that matter) should read:

The Contract Exp Date is not blank
AND
(The Muni Team Account box is checked AND the Region = W
OR
The Profile = Muni Specialist AND the Record Type = Prospect AND the Account Owner’s User Region contains Western)
 
Leslie  KismartoniLeslie Kismartoni
Sorry, mistook the way it was structured... 

After a bit of formatting, the original formula for East is 
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect"), 
        CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN")
    )
)

Given what you said in your response, I think it should be (East):
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "E"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect", CONTAINS(AccountId__r.Owner.User_Region__c, "EASTERN"))
    )
)

(West)
AND(
    NOT( ISBLANK( Contract_Exp_Date__c)), 
    OR( 
        AND(AccountId__r.Muni_Team_Account__c = True, AccountId__r.RegionCode__c = "W"), 
        AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect", CONTAINS(AccountId__r.Owner.User_Region__c, "WESTERN"))
    )
)

I think you split up the
AND(AccountId__r.Owner.ProfileId = "00e30000000jMWI", AccountId__r.RecordType.DeveloperName = "Prospect"),
so that it didn't include the condition that the User Region also had to be specific... In that case, both workflows seem to fire because the above statement is true and the OR returns a true value (it disregards the Region...) 

Lemme know if this works... 
 
This was selected as the best answer
Jennifer HarrisJennifer Harris
It works! I see where the confusion came in now. Also, I can't believe after all this time staring at both of these rules, I did not catch that error previously! Thank you so much for taking the time to help me out. I really appreciate it.

Jennifer
Leslie  KismartoniLeslie Kismartoni
Glad to help...