Help with formula for validation rule on user fields

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I'm trying to create a validation rule requiring 3 fields to be populated for 3 profiles. Here is what i have so far. I gave up after continued syntax errors. I need both Zone Approver Fields and the Sales Report Label field populated for these 3 profiles. The zone approver fields are type "hierarchy" and the Sales Report Label field is a picklist. Thank you in advance!



AND(OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"), 
OR(
LEN(Zone_1_Approver__r.Id)=0),
LEN(Zone_2_Approver__r.Id)=0),
Text(Sales_Report_Label__c)= ""))









share|improve this question









New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    What were the syntax errors? Other users might have trouble reproducing them exactly
    – battery.cord
    46 mins ago










  • They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
    – Kelly
    40 mins ago
















up vote
2
down vote

favorite












I'm trying to create a validation rule requiring 3 fields to be populated for 3 profiles. Here is what i have so far. I gave up after continued syntax errors. I need both Zone Approver Fields and the Sales Report Label field populated for these 3 profiles. The zone approver fields are type "hierarchy" and the Sales Report Label field is a picklist. Thank you in advance!



AND(OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"), 
OR(
LEN(Zone_1_Approver__r.Id)=0),
LEN(Zone_2_Approver__r.Id)=0),
Text(Sales_Report_Label__c)= ""))









share|improve this question









New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2




    What were the syntax errors? Other users might have trouble reproducing them exactly
    – battery.cord
    46 mins ago










  • They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
    – Kelly
    40 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm trying to create a validation rule requiring 3 fields to be populated for 3 profiles. Here is what i have so far. I gave up after continued syntax errors. I need both Zone Approver Fields and the Sales Report Label field populated for these 3 profiles. The zone approver fields are type "hierarchy" and the Sales Report Label field is a picklist. Thank you in advance!



AND(OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"), 
OR(
LEN(Zone_1_Approver__r.Id)=0),
LEN(Zone_2_Approver__r.Id)=0),
Text(Sales_Report_Label__c)= ""))









share|improve this question









New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm trying to create a validation rule requiring 3 fields to be populated for 3 profiles. Here is what i have so far. I gave up after continued syntax errors. I need both Zone Approver Fields and the Sales Report Label field populated for these 3 profiles. The zone approver fields are type "hierarchy" and the Sales Report Label field is a picklist. Thank you in advance!



AND(OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"), 
OR(
LEN(Zone_1_Approver__r.Id)=0),
LEN(Zone_2_Approver__r.Id)=0),
Text(Sales_Report_Label__c)= ""))






validation-rule






share|improve this question









New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 46 mins ago









battery.cord

6,42551742




6,42551742






New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 47 mins ago









Kelly

111




111




New contributor




Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 2




    What were the syntax errors? Other users might have trouble reproducing them exactly
    – battery.cord
    46 mins ago










  • They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
    – Kelly
    40 mins ago












  • 2




    What were the syntax errors? Other users might have trouble reproducing them exactly
    – battery.cord
    46 mins ago










  • They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
    – Kelly
    40 mins ago







2




2




What were the syntax errors? Other users might have trouble reproducing them exactly
– battery.cord
46 mins ago




What were the syntax errors? Other users might have trouble reproducing them exactly
– battery.cord
46 mins ago












They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
– Kelly
40 mins ago




They kept changing with every update. I received extra "," here: LEN(Zone_2_Approver__r.Id)=0), which i know i need. Then i would remove it and get a different error missing ")". Also received "extra LEN". Basically every time i changed something that errored i would get a different error.
– Kelly
40 mins ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













If your'e trying to check for null values you need to wrap your field with ISBLANK



AND(OR( $Profile.Name ="profile1",$Profile.Name="profile2",$Profile.Name="profile3"), 
OR(
ISBLANK(Zone_1_Approver__c),
ISBLANK(Zone_2_Approver__c),
ISBLANK(Text(Sales_Report_Label__c))))


As a best practice try using profile name instead of hard coded Id's






share|improve this answer
















  • 2




    That worked! Thank you!
    – Kelly
    30 mins ago

















up vote
2
down vote













As written, the formula simply has unbalanced parentheses. Treat formulas like algebra, or Excel formulas - you always must balance parentheses and separate formula parameters with commas.



AND(
OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"),
OR(
LEN(Zone_1_Approver__r.Id)=0), // <--- extra parenthesis
LEN(Zone_2_Approver__r.Id)=0), // <--- extra parenthesis
Text(Sales_Report_Label__c) = ""
)
)


You should also, however, see @codeyinthecloud's answer. It's best practice to use ISBLANK() on the relationship field itself rather than relying on behavior when you refer across a non-populated relationship. Additionally, it would be best to use a Custom Permission rather than hard-coding profile references.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Kelly is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f236042%2fhelp-with-formula-for-validation-rule-on-user-fields%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    If your'e trying to check for null values you need to wrap your field with ISBLANK



    AND(OR( $Profile.Name ="profile1",$Profile.Name="profile2",$Profile.Name="profile3"), 
    OR(
    ISBLANK(Zone_1_Approver__c),
    ISBLANK(Zone_2_Approver__c),
    ISBLANK(Text(Sales_Report_Label__c))))


    As a best practice try using profile name instead of hard coded Id's






    share|improve this answer
















    • 2




      That worked! Thank you!
      – Kelly
      30 mins ago














    up vote
    2
    down vote













    If your'e trying to check for null values you need to wrap your field with ISBLANK



    AND(OR( $Profile.Name ="profile1",$Profile.Name="profile2",$Profile.Name="profile3"), 
    OR(
    ISBLANK(Zone_1_Approver__c),
    ISBLANK(Zone_2_Approver__c),
    ISBLANK(Text(Sales_Report_Label__c))))


    As a best practice try using profile name instead of hard coded Id's






    share|improve this answer
















    • 2




      That worked! Thank you!
      – Kelly
      30 mins ago












    up vote
    2
    down vote










    up vote
    2
    down vote









    If your'e trying to check for null values you need to wrap your field with ISBLANK



    AND(OR( $Profile.Name ="profile1",$Profile.Name="profile2",$Profile.Name="profile3"), 
    OR(
    ISBLANK(Zone_1_Approver__c),
    ISBLANK(Zone_2_Approver__c),
    ISBLANK(Text(Sales_Report_Label__c))))


    As a best practice try using profile name instead of hard coded Id's






    share|improve this answer












    If your'e trying to check for null values you need to wrap your field with ISBLANK



    AND(OR( $Profile.Name ="profile1",$Profile.Name="profile2",$Profile.Name="profile3"), 
    OR(
    ISBLANK(Zone_1_Approver__c),
    ISBLANK(Zone_2_Approver__c),
    ISBLANK(Text(Sales_Report_Label__c))))


    As a best practice try using profile name instead of hard coded Id's







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 35 mins ago









    codeyinthecloud

    883216




    883216







    • 2




      That worked! Thank you!
      – Kelly
      30 mins ago












    • 2




      That worked! Thank you!
      – Kelly
      30 mins ago







    2




    2




    That worked! Thank you!
    – Kelly
    30 mins ago




    That worked! Thank you!
    – Kelly
    30 mins ago












    up vote
    2
    down vote













    As written, the formula simply has unbalanced parentheses. Treat formulas like algebra, or Excel formulas - you always must balance parentheses and separate formula parameters with commas.



    AND(
    OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"),
    OR(
    LEN(Zone_1_Approver__r.Id)=0), // <--- extra parenthesis
    LEN(Zone_2_Approver__r.Id)=0), // <--- extra parenthesis
    Text(Sales_Report_Label__c) = ""
    )
    )


    You should also, however, see @codeyinthecloud's answer. It's best practice to use ISBLANK() on the relationship field itself rather than relying on behavior when you refer across a non-populated relationship. Additionally, it would be best to use a Custom Permission rather than hard-coding profile references.






    share|improve this answer
























      up vote
      2
      down vote













      As written, the formula simply has unbalanced parentheses. Treat formulas like algebra, or Excel formulas - you always must balance parentheses and separate formula parameters with commas.



      AND(
      OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"),
      OR(
      LEN(Zone_1_Approver__r.Id)=0), // <--- extra parenthesis
      LEN(Zone_2_Approver__r.Id)=0), // <--- extra parenthesis
      Text(Sales_Report_Label__c) = ""
      )
      )


      You should also, however, see @codeyinthecloud's answer. It's best practice to use ISBLANK() on the relationship field itself rather than relying on behavior when you refer across a non-populated relationship. Additionally, it would be best to use a Custom Permission rather than hard-coding profile references.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        As written, the formula simply has unbalanced parentheses. Treat formulas like algebra, or Excel formulas - you always must balance parentheses and separate formula parameters with commas.



        AND(
        OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"),
        OR(
        LEN(Zone_1_Approver__r.Id)=0), // <--- extra parenthesis
        LEN(Zone_2_Approver__r.Id)=0), // <--- extra parenthesis
        Text(Sales_Report_Label__c) = ""
        )
        )


        You should also, however, see @codeyinthecloud's answer. It's best practice to use ISBLANK() on the relationship field itself rather than relying on behavior when you refer across a non-populated relationship. Additionally, it would be best to use a Custom Permission rather than hard-coding profile references.






        share|improve this answer












        As written, the formula simply has unbalanced parentheses. Treat formulas like algebra, or Excel formulas - you always must balance parentheses and separate formula parameters with commas.



        AND(
        OR(ProfileId ="00e30000001iKyY",ProfileId="00e30000001iKzE",ProfileId="00e30000001iL0B"),
        OR(
        LEN(Zone_1_Approver__r.Id)=0), // <--- extra parenthesis
        LEN(Zone_2_Approver__r.Id)=0), // <--- extra parenthesis
        Text(Sales_Report_Label__c) = ""
        )
        )


        You should also, however, see @codeyinthecloud's answer. It's best practice to use ISBLANK() on the relationship field itself rather than relying on behavior when you refer across a non-populated relationship. Additionally, it would be best to use a Custom Permission rather than hard-coding profile references.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 33 mins ago









        David Reed

        21.8k31640




        21.8k31640




















            Kelly is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Kelly is a new contributor. Be nice, and check out our Code of Conduct.












            Kelly is a new contributor. Be nice, and check out our Code of Conduct.











            Kelly is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f236042%2fhelp-with-formula-for-validation-rule-on-user-fields%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke