Groovy script for sub-task is not working in jira 7

Hi,

We recently upgraded JIRA to version 7.2.4 and script runner plugin 4.3.16 is used.

The groovy scripts used for sub-task creation, assignee, set due date is not working now.

I used the below script in JIRA 6 at additional issue actions section and it was working there.

import com.atlassian.jira.user.ApplicationUsers

issue.summary = sourceIssue.summary + ' - Summary ';
//SET ASSIGNEE FOR Sub-task
if (cfValues['Product]*.value.contains("A")){
cfParent = customFieldManager.getCustomFieldObjectByName('Userpickerfield')
parentMyFieldValue = transientVars["issue"].getCustomFieldValue(cfParent)
if (parentMyFieldValue != null)
{
issue.setAssignee(ApplicationUsers.toDirectoryUser(parentMyFieldValue))
}
//SET DUE DATE
def cf = customFieldManager.getCustomFieldObjectByName('Datefield')
val = issue.getCustomFieldValue(cf) - 9
issue.setDueDate(val)
}
 

I am getting error at bold lines.

Please suggest a solution.

 

Thanks

1 answer

  1. What exactly error you get in first bold Line?
  2. On Second Bold Line: You cannot set the long or int value into Due Date. It has to be Date Object.

1.cfParent- The variable cfParent is undeclared.

2. parentMyFieldValue - The variable parentMyFieldValue is undeclared.

3. getCustomFieldValue-Cannot find matching method

4.issue.setAssignee--Cannot find matching method

even we corrected these errors, sub-tasks are not getting assigned to the custom field value which we entered as users.

If you corrected mentioned error and the error mentioned by me then it should worked

you can write a log.error("==="+ parentMyFieldValue) and check in the log file that you get a expected value for assignee.

like this you can debug your script line by line and find out the where exactly error comes

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

464 views 2 5
View question

Atlassian User Groups

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!

Find my local user group

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

Groups near you