Hello,
I currently have a Script Runner 'Clones an issues and links' post function set up during my 'start work' transition which opens a new task in another project.
Here is the current set up under the 'Addition issue actions' code block:
issue.summary = '[TW] ' + sourceIssue.key + ': ' + sourceIssue.summary issue.description = 'Please document the following Change Request: ' + sourceIssue.summary + ' (' + sourceIssue.key + ').' issue.priorityId = '4' issue.assigneeId = 'Unassigned'
All of this works without issue. I have no import statements or anything else, the above is all of the code.
However, I have a request to add to the 'issue.description' line of the above. The addition will require me to copy the contents of a custom field in the existing task and paste it to the description field of the new task.
I have written it like this:
issue.description = 'Please document the following Change Request: ' + sourceIssue.summary + ' (' + sourceIssue.key + ').\n \n ' + 'Dedicated information for Tech Writing from the change request: ' + sourceIssue.13773
It works up until the '+ sourceIssue.13773', it will not pull in the additional text from the custom field.
Any ideas on what I can do to accomplish this?
Thank you in advance!
I switched the 'Unassigned' with 'null' but it had no affect. I did find this in the logs:
2016-01-12 11:41:07,774 http-bio-443-exec-32 ERROR ab186104 701x562241x1 1goc7p6 153.65.184.112 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2016-01-12 11:41:07,775 http-bio-443-exec-32 ERROR ab186104 701x562241x1 1goc7p6 153.65.184.112 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: DMCP-2336, actionId: 131, file: null
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script79.groovy: 1: unexpected char: 0xA0 @ line 1, column 80.
(sourceIssue).find {it.name == 'Informat
^1 error
Still learning about all of this, I appreciate your patience.
This is weird, could you rewrite the script instead of copy paste ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That worked. Thank you. I will keep that in mind for future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Avril,
The right way to get the value of the custom field is:
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Name of CF'} def value = sourceIssue.getCustomFieldValue(cf) issue.description = 'Please document the following Change Request: ' + sourceIssue.summary + ' (' + sourceIssue.key + ').\n \n ' + 'Dedicated information for Tech Writing from the change request: ' + value
Hope that helps
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Thanos,
Thank you for the information. I've added the def statements to the code, updated and published the workflow. Sadly, when I execute the transition on the task, the page will just refresh, it will not create the new issue at all.
The code now looks like this:
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Information for Technical Writing'} def value = sourceIssue.getCustomFieldValue(cf) issue.summary = '[TW] ' + sourceIssue.key + ': ' + sourceIssue.summary issue.description = 'Please document the following Change Request: ' + sourceIssue.summary + ' (' + sourceIssue.key + ').\n \n ' + 'Dedicated information for Tech Writing from the change request: ' + value issue.priorityId = '4' issue.assigneeId = 'Unassigned'
Is there anything else I am missing?
Thank you for your assistance,
Avril
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you get any errors in you logs ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to replace issue.assigneeId = 'Unassigned' with issue.assigneeId = null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Avril in the script I posted below just replace with {it.name == 'Information for Technical Writing'} and you are done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Thanos, 13733 is the field ID for my custom field which is named "Information for Technical Writing". I figured it would be easier to deal with the ID than the name. Thanks, Avril
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Avril, What is the 13733 ? Is it a name for a custom field ?
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.