Hi all,
Consider the following JSON:
{
"key": "user_details",
"value": [
{
"key": "user1@example.com",
"value": {
"email": "user1@example.com",
"accountId": "account-id-1",
"avatar": "https://avatar-management--avatars.example.com/avatar1.png",
"slackUserId": "slack-id-1"
}
},
{
"key": "user2@example.com",
"value": {
"email": "user2@example.com",
"accountId": "account-id-2",
"avatar": "https://avatar-management--avatars.example.com/avatar2.png",
"slackUserId": "slack-id-2"
}
},
{
"key": "user3@example.com",
"value": {
"email": "user3@example.com",
"accountId": "account-id-3",
"avatar": "https://avatar-management--avatars.example.com/avatar3.png",
"slackUserId": "slack-id-3"
}
}
]
}
I get this from an JIRA Project property that I've set programatically. It contains some user details about the users who work on my project. I want to use in JIRA Automation, to be able to send messages directly to the users or posting comments on JIRA cards using their accountId, etc. You get the drill.
Given I have the variable email, how do I build a smart value "query" that can give me the slackUserId for the the user with given email?
Is this even possible in automation?
Disclaimer: I can structure the object in whatever way I want. Just thought that key-value pair was cute.
To save you some automation, experimentation time...
Once inside of an iterator (e.g., looping over your JSON) data from outside (e.g., your variable email) cannot be accessed.
The workaround is to use your variable and knowledge of the structure to build a dynamic regular expression, and then pass that to the inline iterator with the match() function, finally parsing the data needed using text functions. As a brief example:
.*(\"email\": \"{{email}}\".*)
{{yourData.replace("\n"," ").split("\"key\":").match(varRegEx)}}
Kind regards,
Bill
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.