Hi,
I'm new to Jira and Jira automations using API. I need to get an ID from an API result but i'm not getting how to do this.
I have a manual automation that asks the user which customer/client they want to add in a custom field. The format that users will use to fill in the field is "NAMEOFCLIENT_IDENTIFICATIONNUMBER" for example: ATLASSIAN_123456789
I need to check if the number after _ is already in the custom field. If so, I need to get the ID to update the custom field (can't figure out ou to get the ID)
if the number was not found then the automation will add the client to the custom field (managed how to do this)
I currently have this configuration:
GET https://randstad-pt.atlassian.net/rest/api/3/field/customfield_22471/context/25917/option
the result of this is something like:
"maxResults":100,"startAt":0,"total":1216,"isLast":false,"values":[{"id":"45888","value":"2LIGHT-HEALTHCARESOLUTIONSLDA_514188987","disabled":false},{"id":"45980","value":"A.B.SOARES-INDUSTRIAMETALURGICA,LDA._505608197","disabled":false},{"id":"45426","value":"A.B.V.&MACHADOLDA_506804488","disabled":false},{"id":"45705","value":"A.J.P.-TRANSPORTESRODOVIARIOSDEMERCADORIAS,LDA._503603783","disabled":false},{"id":"45986","value":"A.J.PINTOII-DISTRIBUIÇÃO,LDA._507552393","disabled":false},{"id":"45698","value":"A.MOREIRA&FILHOSS.A._504431609","disabled":false},{"id":"45308","value":"ABANCACORPORACIÓNBANCARIA,S.A.-SUCURSALEMPORTUGAL_980464897","disabled":false},{"id":"45905","value":"ACCELPERCONSULTINGIBERIA,LDA_508992320","disabled":false},{"id":"45382","value":"ACCELYAWORLD,SLUNIPERSONAL_B08132516","disabled":false},{"id":"45149","value":"ACCENTURE-CONSULTORESDEGESTÃO,S.A._502309440","disabled":false},{"id":"45384","value":"ACCENTURE2BUSINESSPROCESSSERVICES,S.A._514711442","disabled":false},{"id":"46123","value":"ACCIONAPORTUGALII-ENERGIAGLOBAL,LDA_513143114","disabled":false},{"id":"45520","value":"ACCORDHEALTHCARE,UNIPESSOAL,LDA_508622263","disabled":false},{"id":"46237","value":"ACIBÉRICA,ACE_517838141","disabled":false},{"id":"45906","value":"ADEGACOOPERATIVADEMANGUALDE,CRL._500008558","disabled":false},{"id":"45513","value":"ADEGACOOPERATIVADEPALMELA,CRL_500008710","disabled":false},{"id":"45917","value":"ADELINOCAVALHEIRO,SOCUNIPESSOAL,LDA_507559126","disabled":false},{"id":"45678","value":"ADLA-ALUMINIUMEXTRUSION,S.A._509838740","disabled":false},{"id":"46168","value":"ADLANEXT,UNIPESSOALLDA_515147281","disabled":false}
For example, if the user adds a client as "TEST_51488987", how can I get the ID from the "value":"2LIGHT-HEALTHCARESOLUTIONSLDA_514188987" so I can update the option with "TEST_51488987"?
Thank you!
Hello @João Cunha
Yes, your API response can be iterated using {{webhookResponse.body}}, BUT,
your requirement of finding the ID based on a value cannot be done if the value you are looking up is also a variable or smart value. It just does not resolve inside the loop.
For example:
{{#webhookResponse.body.values}}{{#if(value, "TEST_51488987")}} {{id}} {{/}}{{/}} <-- will work
{{#webhookResponse.body.values}}{{#if(value, {{teste}})}} {{id}} {{/}}{{/}} <-- Will not work
As you can see, first example works because the lookup value is hardcoded, in second example, your lookup is from user entry, so its in a variable will not work... Thats because in the scope of the iteration, {{teste}} does not exist.
Now to sol;ve your issue.
Only thing I can think of is to store {{webhookResponse.body.values}} in a variable AND then using below thread, you have to create lists of value's and ids and based on if there is a match for a value, get the index and so you can get the ID.
I know what I said is confusing but in a nutshell, what you want cannot be done natively. Option is to store that webreponse.body and somehow parse it.
Hi @João Cunha
If you're using the Web Request Action, then to use it's value in the next steps you need to use the smart value {{webhookResponse}} https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--webhookResponse--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Thanks for your quick reply! I'll try your solutions!
Have a great week.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.