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
Brianna BollettieriBrianna Bollettieri 

Workflow Rule - Opportunity Naming Convention

HI! So I created a workflow rule for an opportunity naming convention and I want to tweak it a little but I've been having some trouble doing so. Here is the worklow rule criteria:

AND(IF(ISNEW() || ISCHANGED(AccountId), true, false), OR(RecordType.Name = 'Leviton Mexico Opportunity' 
, RecordType.Name = 'International Opportunity' 

)

Then I have the following action which is a field update (opportunity name):

IF(
    ISNEW() ||  ISNULL(AccountId),

    IF(
        ISBLANK(AccountId),
        TEXT(End_User__c),
        Account.Name
    )       + " : " +
    Name    + " : " +
    Project_BU__c,

    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)

So right now what happens is that it searches for the account name (end-user), if it is blank it temporarily adds the word End-User as a place holder. What I wanted to change is that I want it to search for the account name (end-user) then if that is blank I want it to search for the distributor and use that. But if both are blank, then I want it to add End-User as a filler. Hope that makes sense and hope someone can assist! Thanks!
Best Answer chosen by Brianna Bollettieri
UC InnovationUC Innovation
I removed the comments and modified a little. Try pasting this directly into the formula box

IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),   
    IF(
        ISBLANK(AccountId),
        IF(
           ISBLANK(Distributor__r.Name),
           TEXT(End_User__c),
           Distributer__r.Name
        ),
        Account.Name
    )   + " : " + Name    + " : " + Project_BU__c,
    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)

All Answers

UC InnovationUC Innovation
Hi Brianna,

Try something like this. You can simply add the check on the related distibutor where you would originally set the filler name in the event of no related account. This way there is a second check for the distibutor before setting the name. Adjustments are necessary since i dont have the API name for the related distibutor object but more on cross object formulas can be found here (https://help.salesforce.com/HTViewHelpDoc?id=fields_creating_cross_object_notes.htm).

IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),
    
    IF(
        ISBLANK(AccountId),
        /*TEXT(End_User__c),*/
        /* Replace this with another IF block to check name on distributor*/
        IF(
           ISBLANK(Distributor__r),
           TEXT(End_User__c),
        ),
        Account.Name
    )       + " : " +
    Name    + " : " +
    Project_BU__c,

    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)

Hope this helps!

AM
Brianna BollettieriBrianna Bollettieri
Hi! I tried that and got an error. "Error: Syntax error. Found ')'." Did I need another IF statement?

IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),
    
    IF(
        ISBLANK(AccountId),
        (TEXT(End_User__c)),
    ),        
        IF(
           ISBLANK(Distributor__r.Name),
           TEXT(End_User__c),
    ),
        Account.Name
    )       + " : " +
    Name    + " : " +
    Project_BU__c,

    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)
UC InnovationUC Innovation
Sorry try this instead

IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),
    
    IF(
        ISBLANK(AccountId),
        /*TEXT(End_User__c),*/
        /* Replace this with another IF block to check name on distributor*/
        IF(
           ISBLANK(Distributor__r.Name),
           TEXT(End_User__c),
           Distributer__r.Name
        ),
        Account.Name
    )       + " : " +
    Name    + " : " +
    Project_BU__c,

    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)
Brianna BollettieriBrianna Bollettieri
This is what I entered and I got an error with this one too. Error: Syntax error. Extra ','


IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),
    
    IF(
        ISBLANK(AccountId),
        TEXT((End_User__c)),
        Account.Name 
    ),

        IF(
           ISBLANK(Distributor__r.Name),
           TEXT(End_User__c),
           Distributor__r.Name
        ),
        Account.Name
    )       + " : " +
    Name    + " : " +
    Project_BU__c,

    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)
UC InnovationUC Innovation
I removed the comments and modified a little. Try pasting this directly into the formula box

IF(
    OR(
       ISNEW(), 
       ISNULL(AccountId)
    ),   
    IF(
        ISBLANK(AccountId),
        IF(
           ISBLANK(Distributor__r.Name),
           TEXT(End_User__c),
           Distributer__r.Name
        ),
        Account.Name
    )   + " : " + Name    + " : " + Project_BU__c,
    IF(
        AND(
            ISCHANGED(AccountId),
            NOT(ISBLANK(AccountId)),
            ISBLANK(PRIORVALUE(AccountId))
        ),
        SUBSTITUTE(Name, TEXT(End_User__c), Account.Name),
        Name
    )
)
This was selected as the best answer
Brianna BollettieriBrianna Bollettieri
I just realized I forgot to activate it which is why it wasn't working. It's been a long day. Thanks so much!! :)