Is it possible to populate custom field with type Label?

Roman Mostyka January 23, 2012

Hi!

I have custom field in my project which has type Label. When user creates an issue I want issue key to be populated in this field. I've tried to do this in postfunction, but got error after clicking "Create" button.
I've tried to find an answer here, but without success. If anybody knows the solution, please give me advise.

Thanks,
Roman.

1 answer

1 accepted

0 votes
Answer accepted
Mizan
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.
January 24, 2012
Hi Roman,
I assume you are using a groovy postfunction.
i hope the below code statements helps , if you have customfeild with same name then use the customfield id to get the customfield object.
CustomField customField = customFieldManager.getCustomFieldObjectByName( "Customfield_name" );
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), issue.getKey()),changeHolder);
Roman Mostyka January 24, 2012

Hi Mizan!

Thanks for the quick response, but I'm quite newby in JIRA and don't use any programming language in postfunction (and even don't know how to do that :) ).
The problem I have is that I want to add to "Create" step of issue workflow standard postfunction (list of which you can see when trying to add postfucntion) which will add to custom field with type label issue key after user click "Create" button. I've tried "Copy Value From Other Field" postfunction, but I've gor the error "Error creating issue: Unable to copy value from 'Key' to 'Epic/Theme'". It works on any next step, but on "Create Issue" step it doesn't work. I've tried to do this with "Update Issue Custom Field" postfunction using field id (I want to add issue key and used %{00015} for adding value from issue key field (by the way, is it correct?)), but I've got the error "Error creating issue: Unable to update custom field 'customfield_10400 - Epic/Theme' in issue [new issue]".

Thanks,
Roman.

Mizan
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.
January 24, 2012

I guess you have jira suite utilities plugin installed. After you add the post function to 'copy field from another field' on the create transition , move down the postfunction one step i.e. after the issue is created .this may work.

Roman Mostyka January 24, 2012

It works, but this is workaround which I have now. I'm interesting if it's possible to do on "Create Issue" step since I have several steps after and it's inconvenient to add the same postfunction to each step, especially taking into account that all these steps can be repeated according workflow and only one step, "Create Issue", can't be repeated.
But anyway thank you for your answers, I very appreciate this.

Mizan
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.
January 24, 2012

Welcome , still try on the "Create Issue" step , after you add the postfunction you will see option move down below your postfunction. move down your postfunction below "issue originally get created".

Roman Mostyka January 24, 2012

OK, now I see what you've meant. And it works, thanks!!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events