I have a project that receives data from an external widget, including a reporter's email address.
I've successfully extracted the email and can look up the corresponding user in my Service Desk. However, the user lookup can return multiple accounts with the same email, differentiated by accountType
(either 'atlassian' or 'customer').
I need a reliable method to extract the accountId
specifically for the account where accountType
is 'atlassian'. While the 'atlassian' account often appears as the first element in the web response body, I need a solution that works regardless of the element order. - This is in order to set the reporter field to the correct reporter.
Is it possible to achieve this using advanced branching or another mechanism to iterate through the response body data and filter for the 'atlassian' accountType
?
Where are you performing that endpoint call and search: in an automation rule, external application, etc.?
If in an automation rule, you could filter the {{webResponse}} values for the accountType using smart value, list filtering:
{{#webResponse.body.values}}
{{#if(equals(accountType, "atlassian"))}}
{{accountId}}
{{/}}
{{/}}
https://community.atlassian.com/forums/Automation-articles/Filtering-smart-value-lists/ba-p/1827588
Kind regards,
Bill
I am working in the automation rule. I will give this a try.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy - in testing, "values" appears blank, I removed it and just went with the .body, and it seems to work as intended.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done!
When testing rules that parse a webResponse, it is a good idea to run a test where the entire {{webResponse.body}} is written to the audit log first. Then compare that to what is expected to decide how / which attributes to access...and even if it can be accessed as JSON or smart values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Matthew Berzinskas , I assume you're trying to fetch some kind of details from webResponse. In that case you should be able to use smart values for instance to get an element from JSON object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marek Bujak - yes that is correct, I am querying a user by email address and want to ultimately get webResponse.body.accountId
However, the issue is that for many users, querying by email address produces both their Atlassian account id and customer account id, which causes confusion if they have issues reported from a customer account, so the webResponse ends up being an array with body[0] and body[1].
In my test cases, it seems generally body[0] is correct, but I wanted to see if there was a reliable way to filter the webResponse bodies to the one that also had the accountType:atlassian.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.