Hi All, how is it possible to copy creator system field to a string , custom field text using scriptrunner upon creation. using behavior? using listener? postfunctions? please help
Do You want save creator for log? JIRA issue has 'History' tab and there saved who created.
Hi @Andrew . I want to copy the Creator (system field) to a custom field text to display the copy of creator to view screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I made it with postfunc, it work for me.
My example:
import com.atlassian.jira.component.ComponentAccessor
def reporter = issue.reporter.name
def cfm = ComponentAccessor.getCustomFieldManager()
def cfMy = cfm.getCustomFieldObjectByName("myfield")
issue.setCustomFieldValue(cfMy,reporter)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use postfunction it work for me.
Example code:
import com.atlassian.jira.component.ComponentAccessor
def reporter = issue.reporter.name
def cfm = ComponentAccessor.getCustomFieldManager()
def cfMy = cfm.getCustomFieldObjectByName("myfield")
issue.setCustomFieldValue(cfMy,reporter)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrew, I edited the code to make it suit for creator because that is what I need
issue.creator.name
thank you for that . but it returns this error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try it:
...
def reporter = "my test value"
...
if work try next:
...
def reporter = issue.get("reporter").getUsername()
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrew , thanks for helping, what do you mean by "my test value"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just string. After create issue You should get "my test value" in your field. For checking of part script which SET value.
...
def reporter = "some your string :-)"
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrew , where should I put the post function? at the very beginning?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is my sample code, it does not populate the some string to sample custom field, which is a text field
import com.atlassian.jira.component.ComponentAccessor
def creator = "some string"
log.error("kdflkdfk $creator")
def cfm = ComponentAccessor.getCustomFieldManager()
def cfMy = cfm.getCustomFieldObjectByName("Sample")
issue.setCustomFieldValue(cfMy,creator)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If You want set value after creating issue:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andrew , yes I have done that one, but it does not set the value after creating the issu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have put the code there. on post functions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Some log error?
Name of field "Sample"? Try
def cfMy = cfm.getCustomFieldObject("<set ID number>")
<set ID number> you can get here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrew, thank you, the thing that made this discussion go long is that because I did not publish the workflow, cheers bud. thanks for the help. answer accepted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hope you help many more questions in this community. Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.