Hi team,
We are using below workflow code and it is working for single account but throwing error for multiple accounts when iterating and does anyone know how to fix this workflow code?
{
“definition”: {
“start”: “Get Identity”,
“steps”: {
“Define Variable”: {
“actionId”: “sp:define-variable”,
“attributes”: {
“id”: “sp:define-variable”,
“variables”: [
{
“description”: “Building dynamic URL to fetch userlogin.Id from userlogin table”,
“name”: “URL”,
“transforms”: [
{
“id”: “sp:transform:concatenate:string”,
“input”: {
“variableB.$”: “$.getAccounts.accounts[?(@.sourceId == ‘1234’)].nativeIdentity”
}
},
{
“id”: “sp:transform:concatenate:string”,
“input”: {
“variableB”: “'”
}
}
],
“variableA”: “https://test.my.salesforce.com/services/data/v61.0/query/?q=select+ID+FROM+UserLogin+WHERE+USERId='”
}
]
},
“displayName”: “”,
“nextStep”: “HTTP Request”,
“type”: “Mutation”
},
“Define Variable 1”: {
“actionId”: “sp:define-variable”,
“attributes”: {
“id”: “sp:define-variable”,
“variables”: [
{
“description”: “The userlogin patch URL.”,
“name”: “UserLoginPatchURL”,
“transforms”: [
{
“id”: “sp:transform:concatenate:string”,
“input”: {
“variableB.$”: “$.hTTPRequest.body.records[0].Id”
}
}
],
“variableA”: “https://test.my.salesforce.com/services/data/v61.0/sobjects/Userlogin/”
}
]
},
“displayName”: “”,
“nextStep”: “HTTP Request 1”,
“type”: “Mutation”
},
“End Step - Failure”: {
“actionId”: “sp:operator-failure”,
“description”: null,
“displayName”: “”,
“failureName”: "Failed ",
“type”: “failure”
},
“End Step - Failure 1”: {
“actionId”: “sp:operator-failure”,
“displayName”: “”,
“failureName”: “Failed”,
“type”: “failure”
},
“End Step - Success”: {
“actionId”: “sp:operator-success”,
“description”: null,
“displayName”: “”,
“type”: “success”
},
“Get Accounts”: {
“actionId”: “sp:get-accounts”,
“attributes”: {
“getAccountsBy”: “specificIdentity”,
“identity.$”: “$.getIdentity.id”
},
“displayName”: “”,
“nextStep”: “Define Variable”,
“type”: “action”,
“versionNumber”: 1
},
“Get Identity”: {
“actionId”: “sp:get-identity”,
“attributes”: {
“id.$”: “$.trigger.recipient.id”
},
“description”: “Id of the identity”,
“displayName”: “”,
“nextStep”: “Get Accounts”,
“type”: “action”,
“versionNumber”: 2
},
“HTTP Request”: {
“actionId”: “sp:http”,
“attributes”: {
“authenticationType”: “OAuth”,
“method”: “get”,
“oAuthClientId”: “1234”,
“oAuthClientSecret”: “5678”,
“oAuthCredentialLocation”: “oAuthInBody”,
“oAuthScope”: null,
“oAuthTokenUrl”: “https://test.my.salesforce.com/services/oauth2/token”,
“requestContentType”: “json”,
“url.$”: “$.defineVariable.uRL”
},
“catch”: [
{
“next”: “Send Email”
}
],
“displayName”: “”,
“nextStep”: “Define Variable 1”,
“type”: “action”,
“versionNumber”: 2
},
“HTTP Request 1”: {
“actionId”: “sp:http”,
“attributes”: {
“authenticationType”: “OAuth”,
“jsonRequestBody”: {
“IsFrozen”: true
},
“method”: “patch”,
“oAuthClientId”: “1234”,
“oAuthClientSecret”: “5678”,
“oAuthCredentialLocation”: “oAuthInBody”,
“oAuthScope”: null,
“oAuthTokenUrl”: “https://test.my.salesforce.com/services/oauth2/token”,
“requestContentType”: “json”,
“url.$”: “$.defineVariable1.userLoginPatchURL”
},
“catch”: [
{
“next”: “Send Email 2”
}
],
“displayName”: “”,
“nextStep”: “Send Email 1”,
“type”: “action”,
“versionNumber”: 2
},
“Send Email”: {
“actionId”: “sp:send-email”,
“attributes”: {
“body”: “<p class=\“p1\”>Dear Admin,
“context”: {
“EMAIL.$”: “$.getIdentity.attributes.email”,
“displayName.$”: “$.getIdentity.attributes.displayName”,
“error.$”: “$.hTTPRequest.error.workflowErrorMessage”
},
“recipientEmailList”: [
“ithelpdesk@test4567.com”,
“departure-sailpointnotifications@test4567.com”,
“infoseciag@test4567.com”
],
“subject”: "The salesforce account for ${displayName} failed to disable and freeze. "
},
“displayName”: “”,
“nextStep”: “End Step - Failure”,
“type”: “action”,
“versionNumber”: 2
},
“Send Email 1”: {
“actionId”: “sp:send-email”,
“attributes”: {
“body”: “<p class=\“p1\”>Dear Admin,\n<p class=\“p1\”>The User ${displayName} from Salesforce failed to disable due to an account dependency. The account has been frozen. Please take the necessary action as required..\n<p class=\“p1\”><span data-teams=\“true\”>Please assign the ticket to salesforce team for the further action\n<p class=\“p1\”>Account: ${EMAIL}\n
Thank you,
\nIdentity Management Team
”,“context”: {
“EMAIL.$”: “$.getIdentity.attributes.email”,
“displayName.$”: “$.getIdentity.attributes.displayName”
},
“recipientEmailList”: [
“departure-sailpointnotifications@test4567.com”,
“ithelpdesk@test4567.com”,
“infoseciag@test4567.com”
],
“subject”: “Salesforce account disable Failed for ${displayName}”
},
“displayName”: “”,
“nextStep”: “End Step - Success”,
“type”: “action”,
“versionNumber”: 2
},
“Send Email 2”: {
“actionId”: “sp:send-email”,
“attributes”: {
“body”: “<p class=\“p1\”>Dear Admin,\n<p class=\“p1\”>The User ${displayName} from Salesforce failed to disable due to an account dependency. The account frozen Failed. Please take the necessary action as required..\n<p class=\“p1\”><span data-teams=\“true\”>Please assign the ticket to salesforce team for the further action\n<p class=\“p1\”>Account: ${EMAIL}\n<p class=\“p1\”>Error message: ${error}\n<p class=\“p1\”> \n<p class=\“p1\”>Thank you,\n<p class=\“p1\”> Identity Management Team”,
“context”: {
“EMAIL.$”: “$.getIdentity.attributes.email”,
“displayName.$”: “$.getIdentity.attributes.displayName”,
“error.$”: “$.hTTPRequest1.error.workflowErrorMessage”
},
“recipientEmailList”: [
“infoseciag@test4567.com”,
“ithelpdesk@test4567.com”,
“departure-sailpointnotifications@test4567.com”
],
“subject”: “The salesforce account for ${displayName} failed to disable and freeze.”
},
“displayName”: “”,
“nextStep”: “End Step - Failure 1”,
“type”: “action”,
“versionNumber”: 2
}
}
},
“trigger”: {
“type”: “EVENT”,
“mode”: “advanced”,
“attributes”: {
“filter.$”: “$.accountRequests[?(@.provisioningResult == ‘failed’ && @.accountOperation == ‘Disable’ && @.provisioningTarget == ‘Salesforce’)]”,
“id”: “idn:post-provisioning”,
“integrationId”: null
}
},
“name”: “test-Freezeaccount”,
“description”: “This workflow ensures that when a Salesforce account fails to disable, an automated attempt is made to freeze the account ,an notification email is sent to IT HelpDesk for further action.”
}
Thanks
