Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Updating issue picker value using groovy

kumar jira March 10, 2020

Can someone let me know how to update a issue picker value. 

this is what am using which is not working. 

def issuepicker= ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Issue Picker")

myIssue.setCustomFieldValue(issuepicker, value)

 

 

1 answer

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2020

It kinda depends where you want to execute this script.

Is this a postfunction, listener or somewhere else?

kumar jira March 10, 2020

@PD Sheehan  Yes listener. 

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2020

setCustomFieldValue(issuepicker, value) only sets the mutable issue object (in memory) to the specified value. That should normally be followed by updateIssue()

In a listener, to update a custom field, there are 3 general methods that I'm aware of

  1. IssueService  - validateUpdate() then update()
  2. IssueManager - updateIssue()
  3. OrderableField - updateCustomField()

#1 is preferable because it ensures all validation & permissions are respected. It takes care of logging the change in the issue history and re-indexing the issue. This is closest to replicating the user's action in the UI.

#2 will create the issue history but you must add your own code to update the index

#3 will only update the custom field and leave no trace in the history or index

kumar jira March 11, 2020

@PD Sheehan I have achieved it by giving issue object as value

def filterissue = issueManager.getIssueObject(key)

myIssue.setCustomFieldValue(parentICR , filterissue)

Thank you. 

Suggest an answer

Log in or Sign up to answer