Has anyone tried to get the Atlassian accountID (via Jira) of a user and store it as a variable in a workflow?
Atlassian no longer allows us to create tickets via API using the friendly usernames in picker fields – it now requires the accountID. Has anyone created a workflow where they have to retrieve the accountID for an employee, store it as a custom variable, and then generate a jira ticket from there?
I want to create leaver tickets in Jira using workflows.
In order to generate the leaver ticket, I need to put the employee name in a user picker field.
However, I can’t populate the user picker field with the employee email address or username, I need to search for the employee’s accountID from jira using the email address and then store it as a variable in the workflow?
I have personally not worked on this usecase, but for a similar kind of use case i did the APPROACH 2.
This is what i am assuming [APPROACH 1]:
You have JIRA source configured and it is correlated with the identity.
Account ID on JIRA source is accountID that you want to use to search the user in JIRA
Now if the above scenario is true, then it should be straight forward;
In workflows use getidentity [Action] to get the identity information,
Next, using getAccounts [action] filter such that you get only JIRA Source Account ID,
Once you have that you can perform other operations as required.
This is what i am assuming [APPROACH 2]:
You have JIRA api, to search the user and get the accountID of the user.
Now if the above statement is true, then :
Call the getIdentity [Action] store the email in the variable so it can be used further.
Call the JIRA API and in the api, pass the filter as email address you have received from #1
Once you have the response, parse the response such that you can retrieve the accountID.
i) to achieve this #4 use https://jsonpath.com/ to retrieve specific object “accountID” from JSON response.
ii) once you have the ID, pass it further .
That’s what I was trying to do, but I am struggling with how to pass the value to the variable?
I have the action HTTP Request – that calls the API using the Request URL – https://[myenvironment]/rest/api/3/user/search?query={{$.getIdentity.attributes.email}}
When I called it via Postman, it returns something like this:
So, after the HTTP Request, I add an operation Define Variable and create a new variable called “accountID” like this? (I am not sure what the body is supposed to look like to grab the variable)
Looking at the response it looks like an Json array and as you are only tapping into one account at a time so we should be good to say that there will be one response only hence added [0] and then we get the accountId.
Do update me on what’s the outcome and Hope this helps