Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ScriptRunner Cloud - Select Assignee for Subtask

manoj.abraham December 10, 2019

I'm using ScriptRunner for Jira Cloud.

I set up a post-function to create a subtask upon transition. I would like to be able to choose the assignee from a list of current Jira users at the time the subtask is created (a drop-down list of all Jira users would suffice). I haven't been able to find anything like this in my searches. Can someone out there point me in the right direction or let me know whether this is not possible?

Separately, I've tried using the provided 'Must have Assignee' code, but that doesn't seem to do anything.

issue.fields.assignee != null

Thank you.

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 11, 2019

Hi Manoj.abraham, 

I can confirm that it is not possible to pop up a dialogue form which can be used to select the assignee when creating a subtask with ScriptRunner for Jira Cloud.

The reason for this is due to the fact that Atlassian does not provide the same Java API in Jira Cloud that they do in Jira Server and that Jira Cloud only contains a rest API.

Unfortunately, the Rest API provided by Jira Cloud does not provide us with the API's that would be required to create dialogues or the functionality to dynamically populate fields based on values selected in other fields like you can do with the Behaviours feature on Jira Server.

You can see more detailed information on the differences between ScriptRunner for JIRA Cloud and ScriptRunner for JIRA Server inside of the documentation page located here.

Regards,

Kristian

manoj.abraham December 11, 2019

Thank you, Kristian. I appreciate your detailed answer.

Is it possible for me to set the assignee based on the value in a custom field then? I've been searching for this is as well, but all solutions seem to refer to Jira APIs.

Thanks again.

Manoj

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 11, 2019

Hi Manoj,

I can confirm to set the assignee that you would need to write some code to extract the value from the user field and to save this to a variable in your script.

Your script would then need to make a put request to the issue API to update the issue and to the assignee to the value, you saved in your variable.

I can confirm that we have an example script located here which shows how to set the assignee to the value of a user picker field and you will be able to use this as a reference guide to help create the script that you require to achive your requirement.

Regards,

Kristian

manoj.abraham December 11, 2019

Thanks again, Kristian.

When trying the code snippet, I get the following error on line 31:

[Static type checking] - No such property: null for class: sr.json.issue.issuelinks$3$3 @ line 31, column 21.

I'm not sure if this is an issue in my environment or with the code snippet itself.

If you can help, I'd appreciate. Else, that's fine - you've already given me a lot of information. :)

Thanks,

Manoj

manoj.abraham December 11, 2019

To clarify my last comment, I added the code snippet to the create subtask ScriptRunner post function.

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 12, 2019

Hi Manoj,

Thank you for your response.

I can confirm that if you are using the built-in Create Subtask post function provided by ScriptRunner for Jira Cloud that you can add some code in the Additional Code Box to set the assignee.

This code will get the accountId value off the user picker field on the parent issue and will set it as the assignee.

I can confirm that we have some sample code located here which shows how to do this and that you can use a reference.

In this sample code, you will just need to change customfield_1234  to be the ID for your user picker field.

I hope this helps.

Regards,

Kristian

TAGS
AUG Leaders

Atlassian Community Events