The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How can I generate a UUID and assign to a custom field?

Aswini Vayyala
March 8, 2016

Hi,

I need to generate UUID and assign it to a custom field using a post function script when an issue is opened?

Has anyone done this before?

 

Thanks

Ashwini

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

4 votes
Answer accepted
JamieA
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 Champions.
March 8, 2016

Please try not to cross-post. We need to respond on all channels otherwise it looks like we don't care, which takes us a lot of additional time, and dilutes the value for other people using it.

To repeat:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("My Field")
issue.setCustomFieldValue(cf, UUID.randomUUID().toString())