Hello, I'm using this API to fetch all the Questions and Answers from any form to use inside Jira Automation.
I'm printing the questions and answers from the response which looks like this:
[ { "answer": "<string>",
"choice": "<string>",
"fieldKey": "<string>",
"label": "<string>" } ]
When the form has multiple questions and answers, the returned result sort order is a bit perplexing.
I figure it would return the questions and answers based on the sequence of the fields on the forms, but it seems random.
I was thinking maybe I could add a number to fieldKey but Jira Automation doesn't have a list sort function.
Does this mean I likely have to write my own Forge App to do this?
@David Yu You’re pretty much on the right track here, Jira Automation currently doesn’t provide any built-in function to sort map objects within an array.
One approach you might consider is creating a dynamic lookup table, where the fieldKey acts as the key and the answer/choice value becomes the value in the table. This can sometimes make it easier to retrieve and process the data in a predictable way within the automation rule.
Alternatively, if the automation rule starts becoming too complex or difficult to maintain, you could consider implementing a custom Forge automation action to handle the logic more cleanly.
If this is a one-off requirement, another option would be to create an event-based Forge function that listens to the relevant event and processes the data outside of Jira Automation altogether. This approach can give you much more flexibility compared to trying to force complex logic into an automation rule.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.