Skip to main content
Amin Ahcene ha fatto una domanda in #Validation Rule

I have a validation formula but it doesn't seem to be working correctly. The objective is to restrict certain users from changing the Vendor Green Light field, changes can only be made under specific conditions.

I think i am missing something . Thankd in advance for the support #Validation Rule #Sales Cloud

 

AND(

    NOT($Permission.Override_Validation),

    NOT($Permission.Market_Intelligence),

    $UserRole.Name != "System Administrator",

    OR(

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "MKT only"), 

            ISPICKVAL(Vendor_green_Light__c, "Don't touch"),

            OR(

                $UserRole.Name != "Vendor Manager",

                $UserRole.Name != "Vendor Implementation Lead",

                $UserRole.Name != "Vendor Account Management Lead",

                $UserRole.Name != "Vendor Sales Development Lead",

                $UserRole.Name != "Customer Success Lead",

                $UserRole.Name != "Sales Lead",

                $UserRole.Name != "Data Entry Teamlead",

                $UserRole.Name != "City Lead",

                $UserRole.Name != "Head of Vendor Sales",

                $UserRole.Name != "Head of Vendor Success",

                $UserRole.Name != "Sales Teamlead"

            )

        ),

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "Don't touch"), 

            ISPICKVAL(Vendor_green_Light__c, "MKT only"),

            OR(

                $UserRole.Name != "Vendor Manager",

                $UserRole.Name != "Vendor Implementation Lead",

                $UserRole.Name != "Vendor Account Management Lead",

                $UserRole.Name != "Vendor Sales Development Lead",

                $UserRole.Name != "Customer Success Lead",

                $UserRole.Name != "Sales Lead",

                $UserRole.Name != "Data Entry Teamlead",

                $UserRole.Name != "City Lead",

                $UserRole.Name != "Head of Vendor Sales",

                $UserRole.Name != "Head of Vendor Success",

                $UserRole.Name != "Sales Teamlead"

            )

        ),

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "Don't touch"),

            ISPICKVAL(Vendor_green_Light__c, "Live"),

            OR(

                $UserRole.Name != "Vendor Implementation Lead",

                $UserRole.Name != "Vendor Account Management Lead",

                $UserRole.Name != "Vendor Sales Development Lead",

                $UserRole.Name != "Vendor Teamlead",

                $UserRole.Name != "Customer Success Lead",

                $UserRole.Name != "City Lead",

                $UserRole.Name != "Data Entry Teamlead",

                $UserRole.Name != "Sales Lead",

                $UserRole.Name != "Head of Vendor Sales",

                $UserRole.Name != "Head of Vendor Success",

                $UserRole.Name != "Sales Teamlead"

            )

        ),

       AND(

        AND(

    OR(

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "Don't touch"),

            ISPICKVAL(Vendor_green_Light__c, "MKT only")

        ),

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "Don't touch"),

            ISPICKVAL(Vendor_green_Light__c, "Live")

        )

    ),

    NOT(ISBLANK(TotalOrderGuideProducts__c))),

    OR(

        $UserRole.Name != "Vendor Account Management Rep",

        $UserRole.Name != "Vendor Implementation Rep",

        $UserRole.Name != "Vendor Sales Development Rep",

        $UserRole.Name != "Vendor Sales Rep"

    )

),

        AND(

            ISPICKVAL(PRIORVALUE(Vendor_green_Light__c), "Live"),

            ISPICKVAL(Vendor_green_Light__c, "Don't touch"),

            $UserRole.Name != "System Administrator"

        )

    )

)

 

3 risposte
  1. Steven Trumble (Strum Consulting) Forum Ambassador
    19 feb 2024, 18:12

    I think a big part of your problem is using != inside an OR.

    OR(

    $UserRole.Name != "Vendor Manager",

    $UserRole.Name != "Vendor Implementation Lead",

    $UserRole.Name != "Vendor Account Management Lead",

    ....

    )

    This will always return true. If my role name is Vendor Manager, then it is not Vendor Implemenetation lead, so it is true. If my role name is Vendor implementation lead, then it is not vendor manager, so it is true. If my role name is <any thing else> then it is not vendor manager or vendor implementation lead, so it is true.

     

    You probably want to use AND() instead of OR() here. 

     

    I also receommend you break this up into multiple validatoin rules. This thing is a beast that is too hard to read easily, and as you are find out now, too hard to troubleshoot. 

0/9000