how to make custom field ID same in all the instances

Naveen October 3, 2019

Hello,

I would like to know if there is any way that i could change the custom field ID.

For my DEV instance, if i have a custom field ID as 123456. When i import my project configurations to PROD, the custom field ID changes to some random number.

Was thinking of changing all my custom field ID's (around 500 custom fields) to make it same as in PROD. Because whenever I write a script, I need to change the values in it again in PROD.

Can someone help me with this.

 

Thank you

2 answers

1 accepted

1 vote
Answer accepted
robert Mugabuhamye
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.
October 3, 2019

hello @Naveen .
unfortunately from my understanding, what you are trying to do is not possible. The custom field id is auto-generated and yes you can have a mismatch between the prod and the dev.

what we usually do before developing a new feature/script in dev is we update the data of the dev by the data of prod to align the ids and go from there.

another solution would be to use the name of the field, but you have of course to make sure that our names are unique :(...
Good luck

Naveen October 4, 2019

Hey Thanks Robert,

Could you let me know how to align the data of PROD to DEV.

 

Thanks 

Naveen

robert Mugabuhamye
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.
October 4, 2019

hello @Naveen ,

this is the easiest way: restore from backup 

Regards

2 votes
Payne
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.
October 4, 2019

I have handled this issue in two ways: by identifying fields by name rather than ID, and by referencing ID based upon the environment.

e.g.

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Customer Request Type")

or

boolean devEnv = ComponentAccessor.getApplicationProperties().getString("jira.baseurl").indexOf("jira-dev.MYDOMAIN.com") > -1
boolean testEnv = ComponentAccessor.getApplicationProperties().getString("jira.baseurl").indexOf("jira-test.MYDOMAIN.com") > -1
boolean prodEnv = ComponentAccessor.getApplicationProperties().getString("jira.baseurl").indexOf("jira.MYDOMAIN.com") > -1

at the top of my script, and then

Long linkTypeApprove = devEnv ? 10600 : (testEnv ? 10700 : (prodEnv ? 10850 : 0))
Naveen October 4, 2019

Hey Payne,

Does this help if we have different fields with the same name?

 

Thanks

naveen

Payne
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.
October 4, 2019

If you have 2 or more fields with the same name, you'll want to use the second approach. I'd try to avoid that situation, though, as that could cause headaches with JQL and possibly other areas.

Naveen October 4, 2019

Sure thanks,

Will try it and update you.

 

-Naveen

Suggest an answer

Log in or Sign up to answer