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"?
textField.convertToSingleSelect([
ajaxOptions: [
url: getBaseUrl() + "/rest/api/latest/user/picker",
query: true,
data: [
showAvatar: true,
],
formatResponse: "?",
],
css: "max-width: 500px; width: 180px",
])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Possibly... can't remember. Why don't you just use a user custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie, thank you for your reply.
I have two fields:
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.