'Required If' formula with 2 conditions - Multiple Statuses and Assigned User Attribute

Hi All,

May I please get some help on a 'Required if' formula on a field in the leads module. This is my first post on Sugar Club.

The requirement is setting a field to be required if the status is any of the following (23 different statuses) and the assigned user belongs to a specific business unit (SYCF). We are excluding 2 statuses 'New' and 'Unable to Contact'.

Was able to set the formula with one status and the business unit. But I'm unable to include multiple statuses in the condition.

The formula I have as of now using multiple statuses (testing with just a few as of now) is:

ifElse(and(or(equal($status,"Discussion"),equal($status,"Inspection"),equal($status,"Considering Offer"),equal($status,"Documents Requested")),equal(related($assigned_user_link,"business_unit_c"),"SYCF")),false,true)

Sugar accepts the formula but this field is now required regardless of the status or the users business unit > basically as if I only checked the box required on the field in studio.

Would truly appreciate some kind help with this. Sugar V12.0

Kind Regards,

Sheldon Pereira

Parents
  • Hi  ,

    Welcome to SugarClub! The best practice for validating on one of many different values is to use the isInList function in conjunction with the createList function to define all potential values. There should be no need to do a ifElse with your formula since you only want the field required if both your conditions are satisfied. You just need to begin the formula with a function that natively returns true or false as a result (e.g. and). The formula should look something like this:

    and(
        isInList(
            $status,
            createList(
                "Discussion",
                "Inspection",
                "Considering Offer",
                "Documents Requested"
            )
        ),
        equal(
            related(
                $assigned_user_link,
                "business_unit_c"
            ),
            "SYCF"
        )
    )

    Let me know how it works for you!

    Chris

  • Hi Chris,

    Thank you for the prompt response. Big Fan!

    I did look at 'isinlist' but could figure out the exact formula.

    I've given this a go. However, the field is not longer required under any status or business unit

  • Hi  ,

    I tested in a stock instance of Sugar and the formula works as expected, so here is what I recommend checking:

    1. Go to Admin > Studio > Leads > Fields > Lead Status. Edit the dropdown list and ensure the key value (i.e. the value in brackets) is exactly what you have in your formula. The value is case-sensitive. The formula should not be using the display value. 
    2. Similarly for business_unit_c field in the Users module, check to make sure the value exactly matches (case-sensitive here too) whether that field is a dropdown or text field. 
    3. Since your screen is showing a new lead user creation, ensure the assigned to user on the lead is a user with the SYCF business unit. 

    If that doesn't help, please provide a screenshot of your current Lead Status dropdown list from Studio as well as the configuration (and if applicable, dropdown list) of the Business Unit field on the Users module.

    Chris

  • Hi  

    So I identified my first classic rookie mistake. the status field is lead_status_c and not the stock status_c field.

    Updated the formula. However, works for just the first status in the list 'Discussion' and not the others.

    Ensured the values are exactly as is in the list for status and business unit. 

    It's now working for 3 out of the 4 statuses mentioned.

    Since we are setting this required for 20+ statuses and not required for only 2 > Would you recommend updating the formula where we rather say:

    "Required if status is not NEW or UNABLE TO CONTACT and business unit Is SYCF"

    Here are the dropdown lists,

  • Hi  ,

    I'm glad you made some progress though it's odd the formula still isn't validating for one of the statuses. Your suggestion of simplifying the formula to exclude two statuses should work also. The formula should look like this:

    and(
        not(
            isInList(
                $lead_status_c,
                createList(
                    "New",
                    "Unable to Contact"
                )
            )
        ),
        equal(
            related(
                $assigned_user_link,
                "business_unit_c"
            ),
            "SYCF"
        )
    )

    Chris

Reply Children