Limit the send emai in Loop of the Workflow

Hi All,

Is there any way to limit the send email action inside the loop?? I have comparing the source name eq AD if not send the email to IAM team else some http operation. Any idea how to prevent this?

I have moved the send email to outside the loop but other than that is there any method to overcome within the loop.

Thanks,
Shantha Kumar

Hi @Santhakumar ,

If i can understand correctly, is the Compare String action not working ? Can you share your details of the loop action ?

Thanks,
Shailee

No it’s working fine but it was sending the email as 4 times since i have check whether the loop.sourceName is AD, so the identity test having 6 accounts but the first 4 accounts failing so it sending the email after the loop comes into 5 time it was triggering the http request.

Hi @Santhakumar , so is there any issue any more ? Just trying to understanding what is not working as expected ?

All are working fine but what i want is is there any way to stop the email inside the loop?

If I understand correctly you are sending an email each time you reach that condition, is the issue you are sending too many emails?

Perhaps you only want to send one with all of the captured data?

if you could share a sample of your workflow that will help everyone understand your issue.

i want to send the email only once when the condition not meets but as of now it’s inside the loop so it was sending whenever the condition fails.
Sure will attach the sample here.

ok so you are sending an email every time the source id match and doesn’t match, what is the input for the loop and trigger for the workflow?

Trigger: Identity Attribute changed
Loop Input: $.getAccounts.accounts

So looking at the condition you are sending an email if the sourced is a match and if it doesn’t match?

Yes, that’s correct. Actually for the successfull source match instead of sending email i have used HTTP Request to revoke the sessions in Entra ID.

You could

set a variable outside the loop set to say false
inside the loop set it to true when when you have sent the email but alway check for the variable being false before sending another email.

Instead of using a loop, use “Verify Data Type” with “Exists” operator on getAccounts. If exists, then send HTTP operation and if does not then send email

@iamnithesh I need loop bcz some users have multiple Entra ID source since they are having additional permissions like Admin, Standard account and etc.

In that case you can handle sending email before the loop and then use loop for httpPost like you are doing now

Yes i have already handling that, but just wanna know if we can do something inside the loop?

Here is a thought -

Instead of using GetAccounts step, you can use a HTTP request action to make a search API call to IDN with the query as identity ID and source ID.

If the result body contains a record, then invoke the HTTP action, else send email.

With this approach, you can avoid using loop.

What about getting multiple UPN for the user? Did we get this from search query, i think it’s not??

I believe UPN attribute is part of the source account schema; you should be able to it in the response of the search API.

You can try the search API via postman to analyse the response and use it accordingly within the workflow.