Adds a comment to linked issues when this issue is transitioned

hi.

I am trying to set to the comment value of custom field with Script runner post function "Adds a comment to linked issues when this issue is transitioned".

I am using:

<% out << com.atlassian.jira.issue.CustomFieldManager.getCustomFieldObject('customfield_10806') %>

But its return eror:

2017-12-01 16:25:47,812 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-12-01 16:25:47,812 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: IO-83, actionId: 141, file: null
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.issue.CustomFieldManager.getCustomFieldObject() is applicable for argument types: (java.lang.String) values: [customfield_10806]
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.UpdateBlockedIssues$_doScript_closure1.doCall(UpdateBlockedIssues.groovy:112)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.UpdateBlockedIssues.doScript(UpdateBlockedIssues.groovy:100)

 Can somebody help?

3 answers

1 accepted

0 vote
Micky Caritte Community Champion Dec 01, 2017

Hi Taras,

Have you tried using double quotes on the cutomfield name?

Also, why don't you use Automation to add a comment on transition? That's more intuitive in my opinion and maintenance is transparent, doesn't require any sripting knowledge :)

Hope either suggestion will help!

Cheers

yes, i tried, there is the same error. I can not use automation because it is a Software project. I can not understande why it not work.

Micky Caritte Community Champion Dec 01, 2017

Understood, then you can't use the line above directly: CustomfieldManager is not a static class and needs to be instanciated. I'm not sure why you out the customfield value but I'm sure that you'll need more than this to use CustomFieldManager.

That would imply something like:

CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager();
CustomField cf = cfm.getCustomFieldObject('customfield_10806');
...

Does that help?

Cheers 

thanks for your answer but it also doesn't works. Maybe i must use transientVars? i set value to this field in transition screen.

Micky Caritte Community Champion Dec 01, 2017

Sure, might be an option, let us know if it works!

ok, maybe somebody know how to do it?

@Jamie Echlin [Adaptavist]Hi, maybe you know how to do it?

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

172 views 1 17
Join discussion

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