Hi, I'm using scriptrunner cloud to create subtask on transition.
Sub task is created fine and reporter is set to current user, i also want the assignee set to current user but struggling to find anything for cloud version.
def response = get('/rest/api/2/myself').asObject(Map) assert response.status == 200 def currentUsername = response.body.name issueInput.fields.assignee = [name: currentUsername] as Map
above code has worked for someone else within the post function script but returns error for me
Varible issueInput is undeclared
Hi Derek,
Thank you for your question.
I can confirm that the Create Subtask transition does not have an issueInput parameter in the script context which is why you are receiving the error that you are receiving and that you should change issueInput to be subtask to set the field on the subtask.
I have tasted your code with this change and can confirm that with this change that the subtask gets created with the assignee being set.
I can confirm that you can see all parameters available in the context for your script by clicking the Show me link next to the text which says There are parameters/variables that are automatically available for use within your script: above the code box, and would always recommending checking this to see what parameters are available to the script.
I would also advise changing the line where you get the username to get the accountId parameter rather than the name as Atlassian is removing the name parameters from the API's as part of the GDPR changes mentioned here which means that you will need to reference users by an account ID as references by name will no longer be supported.
If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.
Regards,
Kristian
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.