Help Workflow - Trigger

Dear all, the worfklow we have, sends access by filtering the AD creation operation, today we have two ADs, AD Picpay and AD Picpaybank, I need it to only send the notification when the operation is actually committed or Succes, but if the account has no correlation, the account creation operation “failed” it sends the notification, I need it not to send the notification, and I haven’t found a better filter for that.

follow the filter.

$.accountRequests[?((@.source.name == "AD Picpay" || @.source.name == "AD PicPay Bank") && (@.accountOperation == "Create" && @.provisioningResult == "commited"))]

Hi,

You can use identity attribute for this. Create an identity attribute “ADCreated”, and use a transform to display samAccountName of AD using firstValid.

{
	"type":"firstValid",
	"attributes":{
		"values":[
			{
				"attributes":{
					"attributeName":"samAccountName",
					"sourceName":"AD Picpay"
				},
				"type":"accountAttribute"
			},
			"NOAD"
		]
	}
}

Now use a identityAttributeChange trigger in workflow and send a notification when this identity attribute changes from “NOAD” to something else. This will make sure your AD account got created and correlated, then only identity attribute will change.

And if you want to send access or anything after account creation you can do get accounts in same workflow and use it.

Hope this helps.

-Abhinov


Hello, maybe I expressed myself badly.
Today the workflow starts from a provisioning completed trigger and filters by these lines $.accountRequests[?((@.source.name == “AD Picpay” || @.source.name == “AD PicPay Bank”) && (@.accountOperation == “Create” && @.provisioningResult == “committed”))], but I will demonstrate an example below, even with a failed creation, it ends up sending the notification to the user that the account has been created.

I would like a way to fix this filter so that it doesn’t send any notifications when creation fails

Hi,

I see even if provisioning failed the result will say committed.

In documentation I see there is error in the JSON. You can use to store it in variable and if it contains failed then dont send notification.

Let me know if it works.

-Abhinov

Hi Alvarenga,

You can add another filter using errors attribute. When there is error, you will get the errors attribute as an array in the json response.

Also, I think you can use @.provisioningResult==“SUCCESS”. Check your json response and see what value you are getting bettwen failed account creation and success account creation, in provisioning completed trigger. Once you find the difference, you can design your own filter based on the value differences between those jsons.

1 Like

Hello everyone, I was even able to do some new validations with your support, but I did some tests in which the account operation “Create” is in the second array, this ends up causing an error in the workflow, how do I get it to read the entire accesrequest attribute to find the accountoperation Create correctly?

follow json

{
	"name": "Copy of Copy of Envio de Credencias AD Picpay 3 2",
	"description": "Notificação para criação de conta AD PICPAY para terceiros Tech's e NÃO Techs com validações no Onboarding",
	"modified": "2025-02-17T19:56:25.443534996Z",
	"modifiedBy": {
		"type": "IDENTITY",
		"id": "bc9220cebb1e430b8cec9db87264f798",
		"name": "iam.team"
	},
	"definition": {
		"start": "Compare Strings 5",
		"steps": {
			"Compare Strings": {
				"choiceList": [
					{
						"comparator": "StringDoesNotEquals",
						"nextStep": "Compare Strings 4",
						"variableA.$": "$.trigger.accountRequests[*].provisioningResult",
						"variableB": "failed"
					}
				],
				"defaultStep": "End Step - Failure",
				"description": null,
				"displayName": "",
				"type": "choice"
			},
			"Compare Strings 1": {
				"choiceList": [
					{
						"comparator": "StringDoesNotContains",
						"nextStep": "Compare Strings 6",
						"variableA.$": "$.getIdentity.attributes.email",
						"variableB": "@ext.ppay.me"
					}
				],
				"defaultStep": "Send Email 1",
				"type": "choice"
			},
			"Compare Strings 2": {
				"choiceList": [
					{
						"comparator": "StringMatches",
						"nextStep": "Send Email 2",
						"variableA.$": "$.getIdentity.attributes.email",
						"variableB": "@picpay"
					}
				],
				"defaultStep": "Get Identity 1",
				"type": "choice"
			},
			"Compare Strings 3": {
				"choiceList": [
					{
						"comparator": "StringContains",
						"nextStep": "Send Email 3",
						"variableA.$": "$.getIdentity.attributes.email",
						"variableB": "@ext.ppay.me"
					}
				],
				"defaultStep": "Compare Strings 1",
				"type": "choice"
			},
			"Compare Strings 4": {
				"choiceList": [
					{
						"comparator": "StringContains",
						"nextStep": "Get Identity",
						"variableA.$": "$.trigger.accountRequests[*].source.name",
						"variableB": "AD Picpay"
					}
				],
				"defaultStep": "End Step - Failure 1",
				"displayName": "",
				"type": "choice"
			},
			"Compare Strings 5": {
				"choiceList": [
					{
						"comparator": "StringEquals",
						"nextStep": "Compare Strings",
						"variableA.$": "$.trigger.accountRequests[*].accountOperation",
						"variableB": "Create"
					}
				],
				"defaultStep": "End Step - Failure 2",
				"displayName": "",
				"type": "choice"
			},
			"Compare Strings 6": {
				"choiceList": [
					{
						"comparator": "StringContains",
						"nextStep": "Send Email 4",
						"variableA.$": "$.getIdentity.attributes.email",
						"variableB": "@original.com.br"
					}
				],
				"defaultStep": "Send Email",
				"displayName": "",
				"type": "choice"
			},
			"End Step - Failure": {
				"displayName": "",
				"failureName": "Criação Falhou",
				"type": "failure"
			},
			"End Step - Failure 1": {
				"displayName": "",
				"failureName": "Criação Falhou",
				"type": "failure"
			},
			"End Step - Failure 2": {
				"displayName": "",
				"failureName": "Criação Falhou",
				"type": "failure"
			},
			"End Step — Success 1": {
				"type": "success"
			},
			"End Step — Success 2": {
				"type": "success"
			},
			"End Step — Success 3": {
				"type": "success"
			},
			"End Step — Success 4": {
				"type": "success"
			},
			"End Step — Success 5": {
				"displayName": "",
				"type": "success"
			},
			"Get Identity": {
				"actionId": "sp:get-identity",
				"attributes": {
					"id.$": "$.trigger.recipient.id"
				},
				"nextStep": "Compare Strings 2",
				"type": "action",
				"versionNumber": 2
			},
			"Get Identity 1": {
				"actionId": "sp:get-identity",
				"attributes": {
					"id.$": "$.getIdentity.managerRef.id"
				},
				"nextStep": "Compare Strings 3",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Ol&aacute; ${gestor},</p>\n<p>O sistema OneId criou uma conta para ${nomeCompleto} da empresa ${empresa} no sistema ${source}. Aqui est&atilde;o os detalhes da conta pra voc&ecirc; acompanhar:</p>\n<table style=\"border-color: #A9A9A9;\" border=\"1\">\n<tbody>\n<tr style=\"background: #A9A9A9; border-color: #A9A9A9;\">\n<th>Nome</th>\n<th>E-mail</th>\n<th>Senha</th>\n</tr>\n<tr style=\"background: #D3D3D3; border-color: #A9A9A9;\">\n<td>${nomeCompleto}</td>\n<td>${emailExt}</td>\n<td>{{$.getIdentity.attributes.lastname}}?%{{$.getIdentity.attributes.globalid}}</td>\n</tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>Se tiver alguma d&uacute;vida, entre em contato com o time de Gest&atilde;o de Acessos.</p>\n<p><br><br>Atenciosamente, <br>Gest&atilde;o de Acessos</p>",
					"context": {
						"emailExt.$": "$.getIdentity.attributes.emailExt",
						"empresa.$": "$.getIdentity.attributes.empresa",
						"gestor.$": "$.getIdentity.managerRef.name",
						"nomeCompleto.$": "$.getIdentity.attributes.nomeCompleto",
						"source.$": "$.trigger.accountRequests[0].source.name"
					},
					"recipientEmailList": [
						"[email protected]"
					],
					"subject": "Informações de acesso do novo Prestador Picpay"
				},
				"description": null,
				"nextStep": "End Step — Success 1",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email 1": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Ol&aacute; ${gestor},</p>\n<p>O sistema OneId criou uma conta para ${nomeCompleto} da empresa ${empresa} no sistema ${source}. Aqui est&atilde;o os detalhes da conta pra voc&ecirc; acompanhar:</p>\n<table style=\"border-color: #A9A9A9;\" border=\"1\">\n<tbody>\n<tr style=\"background: #A9A9A9; border-color: #A9A9A9;\">\n<th>Nome</th>\n<th>E-mail</th>\n<th>Senha</th>\n</tr>\n<tr style=\"background: #D3D3D3; border-color: #A9A9A9;\">\n<td>${nomeCompleto}</td>\n<td>${email}</td>\n<td>{{$.getIdentity.attributes.lastname}}?%{{$.getIdentity.attributes.globalid}}</td>\n</tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>Se tiver alguma d&uacute;vida, entre em contato com o time de Gest&atilde;o de Acessos.</p>\n<p><br><br>Atenciosamente, <br>Gest&atilde;o de Acessos</p>",
					"context": {
						"email.$": "$.getIdentity.attributes.email",
						"empresa.$": "$.getIdentity.attributes.empresa",
						"gestor.$": "$.getIdentity.managerRef.name",
						"nomeCompleto.$": "$.getIdentity.attributes.nomeCompleto",
						"source.$": "$.trigger.accountRequests[0].source.name"
					},
					"recipientEmailList": [
						"[email protected]"
					],
					"subject": "Informações de acesso do novo Funcionário Picpay"
				},
				"nextStep": "End Step — Success 2",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email 2": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Ol&aacute;, PicPayLover!</p>\n<p>&nbsp;</p>\n<p>Seja muito bem-vindo(a)!</p>\n<p>Somos do time de Acessos e compartilhamos abaixo suas credenciais para o primeiro acesso ao seu equipamento corporativo.</p>\n<p>Confira:</p>\n<p><strong>Usu&aacute;rio:</strong> ${email}</p>\n<p><strong>Senha:</strong> {{$.getIdentity.attributes.lastname}}?%{{$.getIdentity.attributes.globalid}}</p>\n<p>Se voc&ecirc; precisar de suporte com a configura&ccedil;&atilde;o da sua m&aacute;quina, entre em contato com o nosso time de TI Tech Corp, pelo <strong>e-mail: [email protected]</strong> ou, &nbsp;para quem j&aacute; estiver logado em nosso sistema, voc&ecirc; dever&aacute; abrir um chamado no JIRA.</p>\n<p>Atenciosamente,<br>Gest&atilde;o de Acessos | Picpay</p>\n<p><br><em>Aten&ccedil;&atilde;o! Esta &eacute; uma mensagem autom&aacute;tica. Por favor, n&atilde;o responda.</em></p>\n<p><em>&nbsp;</em></p>",
					"context": {
						"email.$": "$.getIdentity.attributes.email",
						"empresa.$": "$.getIdentity.attributes.empresa",
						"gestor.$": "$.getIdentity.managerRef.name",
						"nomeCompleto.$": "$.getIdentity.attributes.nomeCompleto",
						"source.$": "$.trigger.accountRequests[0].source.name"
					},
					"from.$": "",
					"recipientEmailList": [
						"[email protected]"
					],
					"replyTo": null,
					"subject": "Bem Vindo PP-Lover"
				},
				"nextStep": "End Step — Success 3",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email 3": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Ol&aacute; ${gestor},</p>\n<p>O sistema OneId criou uma conta para ${nomeCompleto} da empresa ${empresa} no sistema ${source}. Aqui est&atilde;o os detalhes da conta pra voc&ecirc; acompanhar:</p>\n<table style=\"border-color: #A9A9A9;\" border=\"1\">\n<tbody>\n<tr style=\"background: #A9A9A9; border-color: #A9A9A9;\">\n<th>Nome</th>\n<th>E-mail</th>\n<th>Senha</th>\n</tr>\n<tr style=\"background: #D3D3D3; border-color: #A9A9A9;\">\n<td>${nomeCompleto}</td>\n<td>${email}</td>\n<td>{{$.getIdentity.attributes.lastname}}?%{{$.getIdentity.attributes.globalid}}</td>\n</tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>Se tiver alguma d&uacute;vida, entre em contato com o time de Gest&atilde;o de Acessos.</p>\n<p><br><br>Atenciosamente, <br>Gest&atilde;o de Acessos</p>",
					"context": {
						"email.$": "$.getIdentity.attributes.email",
						"empresa.$": "$.getIdentity.attributes.empresa",
						"gestor.$": "$.getIdentity.managerRef.name",
						"nomeCompleto.$": "$.getIdentity.attributes.nomeCompleto",
						"source.$": "$.trigger.accountRequests[0].source.name"
					},
					"recipientEmailList": [
						"[email protected]"
					],
					"subject": "Informações de acesso do novo Prestador Picpay"
				},
				"nextStep": "End Step — Success 4",
				"type": "action",
				"versionNumber": 2
			},
			"Send Email 4": {
				"actionId": "sp:send-email",
				"attributes": {
					"body": "<p>Ol&aacute; ${email},</p>\n<p>O sistema OneId criou uma conta para ${nomeCompleto} da empresa ${empresa} no sistema ${source}. Aqui est&atilde;o os detalhes da conta pra voc&ecirc; acompanhar:</p>\n<table style=\"border-color: #A9A9A9;\" border=\"1\">\n<tbody>\n<tr style=\"background: #A9A9A9; border-color: #A9A9A9;\">\n<th>Nome</th>\n<th>E-mail</th>\n<th>Senha</th>\n</tr>\n<tr style=\"background: #D3D3D3; border-color: #A9A9A9;\">\n<td>${nomeCompleto}</td>\n<td>${emailExt}</td>\n<td>{{$.getIdentity.attributes.lastname}}?%{{$.getIdentity.attributes.globalid}}</td>\n</tr>\n</tbody>\n</table>\n<p>&nbsp;</p>\n<p>Se tiver alguma d&uacute;vida, entre em contato com o time de Gest&atilde;o de Acessos.</p>\n<p><br><br>Atenciosamente, <br>Gest&atilde;o de Acessos</p>",
					"context": {
						"email.$": "$.getIdentity.attributes.email",
						"emailExt.$": "$.getIdentity.attributes.emailExt",
						"empresa.$": "$.getIdentity.attributes.empresa",
						"gestor.$": "$.getIdentity.managerRef.name",
						"nomeCompleto.$": "$.getIdentity.attributes.nomeCompleto",
						"source.$": "$.trigger.accountRequests[0].source.name"
					},
					"recipientEmailList": [
						"[email protected]"
					],
					"subject": "Informações de acesso do novo Prestador Picpay"
				},
				"description": null,
				"displayName": "",
				"nextStep": "End Step — Success 5",
				"type": "action",
				"versionNumber": 2
			}
		}
	},
	"creator": {
		"type": "IDENTITY",
		"id": "bc9220cebb1e430b8cec9db87264f798",
		"name": "iam.team"
	},
	"trigger": {
		"type": "EVENT",
		"attributes": {
			"filter.$": "$.accountRequests[?(@.source.name == \"AD Picpay\" || @.source.name == \"AD Picpay Bank\" && @.accountOperation== \"Create\")]",
			"id": "idn:post-provisioning"
		}
	}
}