Fixing a flow that uses the LoginName parameter

The LMS365 connector allows use of LMS365 data in Microsoft Power Automate flows. With the help of different triggers you can get various outputs. However, if you use the LoginName parameter, it can cause your flow to fail, even though it may look like the run attempt has been successful.

This article provides simple steps on fixing this behavior and successfully use the LoginName parameter in Power Automate flows.

 

In this article

 

Description of the issue

Let's create a simple flow that will purge users' data after they have been deleted/disabled in Azure Active Directory (AAD).

 

 

When you test the trigger, this flow should work well, and it will appear as if the run was successful.

However, when you check the user data via API, you will see that the record somehow hasn't been purged. In the flow outputs, you should also find an error:

 

 

Solution for the issue

The reason for this behavior is the format of the LoginName output. It may look like this:

i:0#.f|membership|ivanivanov@efisup.onmicrosoft.com
i:0#.f|membership|ivanivanov_google.com#EXT#@efisup.onmicrosoft.com

 

In both cases, it's the # symbol that causes the error. Therefore, we need to get rid of this symbol so the flow will work. There are several methods to do this:

 

1. Manually replace # symbols with %23

It will work for flows where you manually input the login name.

 

2. Initialize variable and use compose action to replace # automatically

There are two functions that can be used: encodeUriComponent (find more information on usage of Encode Uri in Power Automate here) and replace.

Below, is an example of how the encodeUriComponent fuction can be used in flows that are manually triggered:

 

 

As you can see, the encodeUriComponent(variables('OriginalUserLogin')) expression is used in the Compose action. For the replace function, the expression should be replace(variables('OriginalUserLogin'), '#', '%23').

3. Use another output 

For an automated flow, you can use another output that doesn't contain special symbols.

For the purge action, you can use the DirectoryObjectId parameter. If you replace LoginName with this parameter, the flow should work. This way, you will be using the output: Users('@{items('Apply_to_each')?['DirectoryObjectId']}')/Purge in the Uri field.

 

Was this article helpful?
0 out of 0 found this helpful

Comments

Article is closed for comments.