Is is possible to get the value of a custom field from one project and update it in another project

Shivani Chauhan August 23, 2018

I have a requirement where I need to update the value of a custom field in a project when the issue in another project(B) transitions from fulfillment to done.

 

The catch here is, the value that needs to be updated is stored in another project.

So basically when a issue is created in Project 'B', it has linked project project and linked issue mention, I need to get the value [bugdet value] from the linked issue[this is from another project] and update it in the linked project

Is this possible using the rest API? or another ways? I am quite new with the development Zone in JIRA and would like to understand if this is feasible?

 

 

Thanks,

1 answer

0 votes
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 23, 2018

You can do it with Scriptrunner.

Shivani Chauhan August 23, 2018

Hi Nir, 

Thank you for your response. Could you please let me know with the intial logic or steps that I should start with?

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 24, 2018

OK, i will just give you some points.

In your workflow create a post-function of type scriptrunner in the transition you want.

In the script, you should get your linked issues with :

issueLinkManager.getOutwardLinks(issue.getId()).findAll { it.issueLinkType.name.contains("Epic")}

 try "getOutwardLinks" or "getInwardLinks", change "Epic" to your link name.

once you get your links, you can get your issue in another project from it.

Once you get the issue from another project, update it's customfield like this:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def myCustomField= customFieldManager.getCustomFieldObject("customfield_11111") //replace 11111 with the id of your customfield

IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
def customFieldValueInCurrentIssue = issue.getCustomFieldValue(myCustomField)

myCustomField.updateValue(null, issue, new ModifiedValue(issueInAnotherProject.getCustomFieldValue(myCustomField), customFieldValueInCurrentIssue), changeHolder);

 

Hope you can manage work with this.

I wrote you all the hard parts, the rest is easy 

Suggest an answer

Log in or Sign up to answer