Expression builder multiple IIF nesting

yeooandyni 146 Reputation points
2024-06-14T16:05:26.19+00:00

Hey folks,

I've run into a problem in building expressions.

As part of our Workday to Active Directory provisioning, we want to have the email address built out based on Company name. However, we have multiple company names under our AD user profiles and are struggle to work out how to nest the IIF statements to say if company1 then return ******@company1.com, else if company2 then return ******@company2.com, else if company3 then return ******@company3.com, else return ******@company1.com.

This is what I've been playing about with:

IIF([Company]="company1",JOIN("@",[UserID],"company1.com"),IIF([Company]="company2",JOIN("@",[UserID],"company2.com")),IIF([Company]="company3",JOIN("@",[UserID],"company3.com")),JOIN("@",[UserID],"company1.com"))

At this point I assume it either can't be done - too many IIF statements - or I've got the parenthesis messed up.

Thanks.

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

Accepted answer
  1. Givary-MSFT 35,621 Reputation points Microsoft Employee Moderator
    2024-06-26T04:59:45.5633333+00:00

    @yeooandyni Apologies for the delayed response, for the above mentioned requirement below expression should help -

    IIF([Company]="company1",JOIN("@",[UserID],"company1.com"),   IIF([Company]="company2",JOIN("@",[UserID],"company2.com"),IIF([Company]="company3",JOIN("@",[UserID],"company3.com"),JOIN("@",[UserID],"company1.com"))))

    Although, for this scenario using switch is recommended as it is easier to maintain, example:

    Switch([Company], Join("",[UserID],"@company1.com"),

    "company2", Join("",[UserID],"@company2.com"),

    "company3",Join("",[UserID],"@company3.com"))

    Let me know if you have any further questions, feel free to post back.

    Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.