I am trying to create a custom field which functions like a Component field from a specific project. That means I will be able to pick the components from that project and add them to this custom field. I tried something like this under Behaviours/Initialiser Function:
getFieldByName("Linked Components").convertToMultiSelect([ ajaxOptions: [ url : getBaseUrl() + "/rest/api/2/project/10110/components", query: true, formatResponse: "general" ] ])
It did not work, and I can't seem to find any documentation on how ajaxOptions really works.
The rest api you have chosen doesn't return the components in the right "shape" as required by the "general" formatted.
So you need to write your own endpoint - which I have done here: https://gist.github.com/jechlin/4c9817846ed98f025053003846541a6f
Then I changed the initialiser to:
def projectId = issueContext.projectId getFieldById("summary").convertToMultiSelect([ ajaxOptions: [ url : getBaseUrl() + "/rest/scriptrunner/latest/custom/components?projectId=$projectId", query: true, formatResponse: "general" ] ])
Note I am passing the project ID to get the components from, using the project for the current issue, but it need not be.
Jamie, I have a similar question.
Is it possible to convert text field to user picker using standard REST Endpoint? In other words, are there other options for formatResponse exept "general" and "issue"?
url: getBaseUrl() + "/rest/api/latest/user/picker",
css: "max-width: 500px; width: 180px",
Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs