Hello,
In my jira instance we had a custom field called "Super Power" (user picker type)this field already set to default value 'SIVA' by using custom field configure. But here the issue is when issue is moved to project A to project B the custom field also reflects the same value 'SIVA' but i need a different value 'RAJA' in project B.
I wrote a script using scriptrunner behaviour
import com.atlassian.jira.component.ComponentAccessor
def FieldName = getFieldByName("<Super Power>")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(FieldName.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "<RAJA>" }
FieldName.setFormValue(optionToSelect.optionId)
And finally mapped the issuetype and project B to behaviour. But the above script not working can any one please help me how to solve this issue.
Thanks,
Siva.
@siva - You need to write groovy script to update the custom field on the script listener for move issue events. The behavior script is not going to work. see the screenshot
Pls Accept the answer if you find this helpful. Let me know if you have any queries
Thanks for the reply and i tried in script listener and it shows so many errors in this code can please help with code how to update custom field (PM Lead) when issue moved from one project to another project
Thanks,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@siva - You need to write groovy script instead of behavior script. You can refer bellow.
instead of current user you can get the object of user which you want to update.
Please Accepts the answer if you find helpful
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// a user custom field
def userCf = customFieldManager.getCustomFieldObjectByName("User Picker Customfield Name")
def currenrUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issue.setCustomFieldValue(userCf, currenrUser)
ComponentAccessor.getIssueManager().updateIssue(currenrUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The script you sent showing few errors here the screen shot below
can you please help me with script i'm new to script runner and your help much appreciated.
Thanks,
Siva.
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.
Thanks for the reply but i didn't get you what you are asking can you please elaborate little bit.
Thanks,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when are you calling the script to be executed ?
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.