If i got it right, you want to get the value of a custom field in jira logs, when a workflow is executed.
If so, use a groovyscript in your post function like the following:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "customfield_name" ); log.warn ("value: "+ issue.getCustomFieldValue( customField_name))
Test it first.
Cheers
What do you mean by "can i perform transition associated with this custom field?"
You just have to create a file and use it in a scripted post function of your workflow.
Have a look at jamie's plugin page and you will clarify most of things.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to use above code, but seems
ComponentManager.getInstance().getCustomFieldManager(); decrecated.
How can I get single line customer value using JIRA 7.1.2 API?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to use above code, but seems
ComponentManager.getInstance().getCustomFieldManager(); decrecated.
How can I get single line customer value using JIRA 7.1.2 API?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use:
import com.atlassian.jira.component.ComponentAccessor ComponentAccessor.getCustomFieldManager()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did have following lines in my post:
import
com.atlassian.jira.component.ComponentAccessor
def firstnameTypeCF = customFieldManager.getCustomFieldObject("First Name")
def firstnameFieldV = parentIssue.getCustomFieldValue(firstnameTypeCF)
But failed with following error:
2016-09-12 13:06:51,034 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2016-09-12 13:06:51,041 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: TPSHR-1372, actionId: 1, file: <inline script> java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:896) at com.atlassian.jira.issue.Issue$getCustomFieldValue$1.call(Unknown Source) at Script58.run(Script58.groovy:71)
I don't know why it's failed?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The CustomFieldManager.getCustomFieldObject method signature takes a custom field ID (either a Long or a string that has the numeric ID). You want the ...ByName signature that Kostas used. Otherwise, the custom field manager will probably return null, and you'll get that null pointer exception.
import com.atlassian.jira.component.ComponentAccessor; def customFieldManager = ComponentAccessor.getCustomFieldManager() def firstName = customFieldManager.getCustomFieldObjectByName("First Name"); def firstnameFieldV = parentIssue.getCustomFieldValue(firstName)
I'm also assuming that the parentIssue variable is defined elsewhere, and that you've omitted it for brevity. If not, you may need to manually define that, depending on the context you're running this script under.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have no idea what you mean. If Kostas' answer does not help, can you explain a bit more what you're trying to do.
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.