cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create alternative UPN for users with same name

Hi,

 

I'm building a flow to create an account for new students triggered by a form. It creates a UPN like this: "first_name.last_name@school.com".

 

Suppose John Doe is a student. He has the UPN "John.Doe@school.com". 

Next, suppose a new student has the same name. He needs a unique UPN: "John.Doe2@school.com". 

 

In order to do this, I have Power Automate Search for users (V2) with the UPN as the search term.

Then, I Initialize a viariable, being the integer 1.

Then, a Condition should check whether the UPN already exists in the SharePoint list with students. If it doesn't, it should create the first type of UPN (i.e. "John.Doe@school.com "). If it does, it should create the alternative UPN by Incrementing the integer 1 variable (i.e. "John.Doe2@school.com "). 

 

This all works fine. The problem is I can't get the condition right. This is what I have as the condition:

[value] of Search for users (V2) contains [UPN]

If yes create alternative UPN

If no create standard UPN

 

But somehow, the condition always returns true, so it always creates the alternative UPN. And when I set the condition to "does not contain" it creates the standard UPN (obviously) but when I run the flow again to have it create the alternative UPN (since the standard UPN already exists), it simply says "UPN already exists" upon creating the account. 

 

NedviceArjen_0-1597402910895.png

How do I define the proper condition?

 

 

Best,

 

Arjen

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

Please try the following configuration:

13.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Mira_Ghaly
Dual Super User
Dual Super User

@Anonymous

TRy to add the condition as :

length(outputofyoursearchaction) greater than 0

Create alternative UPN

Else

Create UPN

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

Please try the following configuration:

13.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Now, suppose I would like to create a condition, such that:

 

- if first_name.last_name@school.com already exists, create first_name.last_name2@school.com

- if first_name.last_name2@school.com already exists, create first_name.last_name3@school.com

- etc.

 

Seems doable but I'm very new to Power Automate so I'm not sure where to begin.

Helpful resources

Users online (4,096)