set parent custom field value

Hii,

how can I set a parent custom field value?

I've already tried the following code:

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Single Select");
def value = ComponentAccessor.optionsManager.getOptions(cf.getRelevantConfig(issue))?.find { it.toString() == 'Value'};
issue.parentObject.setCustomFieldValue(cf, value);
issue.setCustomFieldValue(cf, value);

 The last code line does work, so the customfield value of the subtask customfield gets updated. Unfortunately, the customfield of the parent Issue does not get the new value!

 

Best regards,

Louisa

1 answer

Hi @Louisa Pabst,

If you want to avoid having to write code, you can also accomplish it using the Update on Transition for JIRA add-on, which supports using/setting system and custom fields from parent issues… including making the update conditional based on an expression or a JQL query.

This recipe shows how it is used to add a comment to a linked issue during a workflow transition, but the overall approach applies to your Use Case as well.

I don't really wanna use an extra add-on! But thanks for your response!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

784 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you