Use Loop in Workflow to Disable a account in a source

Hello, I’m trying to create a workflow that collects a list of identities and disables access to a source if it meets the requirements of the created search.
However, when it enters the loop, it even identifies the identities, but does not find the accounts. How can I adjust it so that it reads accounts and deactivates?

I use this configuration:

and this

Hi @wanderson_marchi88 ,

Welcome to Developer Community!!!

In the Get Identity step the Accounts by Identity should be “$.loop.loopInput”. Could you try this and let me know if this works

image
That should look something like this

1 Like

Works fine this part.

But now I have other problem in the “Manage Accounts” don’t found.

I used:
$.getAccounts.accounts[?(@.sourceId == ‘85c3ff0ed52d41e0afe31b1b5c7c78e5’)].id

Thats correct?

$.getAccounts.accounts[?(@.sourceId == “85c3ff0ed52d41e0afe31b1b5c7c78e5”)].id - Can you try this

Same error, the list is ok, with 3 employees, now read the accounts, but don’t disable the accounts

$.getAccounts.accounts[?(@.sourceId == ‘85c3ff0ed52d41e0afe31b1b5c7c78e5’)].nativeIdentity - Try this once

1 Like

Same error:

    },
    "manageAccounts": {
      "failedAccounts": [
        "$.getAccounts.accounts[?(@.sourceId == ‘85c3ff0ed52d41e0afe31b1b5c7c78e5’)].nativeIdentity"
      ],
      "successfulAccounts": null

Since ID is different in test and production environment, I recommend to use sourceName instead of ID in disable operation. Use following code. You have to enclose your code in double curly braces to make it work.


{{$.getAccounts.accounts[?(@.sourceName ==“Name Of Source”)].id}}

If you want to use id, this should work fine.

{{$.getAccounts.accounts[?(@.sourceId == “85c3ff0ed52d41e0afe31b1b5c7c78e5”)].id}}

Hope it helps.

The issue is not with the Source ID/Source Name, Source Name can also be different in production…there might be extra spaces in that aswell :upside_down_face:

Under the select accounts instead of Enter Value. Its should be
image

also as @kdfreeman if you are using value it should always in between {{ }}

I am not saying there is issue with ID. I am saying that it is best practice to use sourceName because most of the time sourceName in test is same in production. So, when you move your workflow, you need minimal modification.

Enclosing with curly braces should resolve the issue. I had similar situaion and it had worked fine using double curly braces.

2 Likes

Agree!! missed that Enter Value and Choose Variable piece.

@wanderson_marchi88 if you use Enter Value the entire path should be between {{ }}

If you use choose Variable that can be direct

1 Like

Thats correct?

Use double quotes for Source Name -{{$.getAccounts.accounts[?(@.sourceName== “Your Source Name”)].id}}

3 Likes

Works fine. Thank you

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.