Hi Community,
I have a requirement in Jira Cloud where I need a custom field (let’s call it Document Number) to automatically increment every time a new issue is created.
For example:
Is there any way that can I achieve this?
Note: We are using jira cloud
Hello @Prathap DL ,
To do this, you'll need to use an rule automation to retain the created issue.key every time a new ticket is opened. Once you have this data, you can make a web request to get the ticket issue.key - 1 (previous ticket). With that REST API call, you obtain the custom field you want to increment by 1 from the webresponse.body. The last part is an action in the automation to edit that field in the created(trigger) ticket.
regards
hi @Pedro Olmo
Thanks for the answer.
As I'm new to this Jira automation, could you please provide the working automation rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Prathap DL ,
I will prepare it for you but keep in mind that you will need to have an access token from a user via REST API. You will also need the custom field number.
Manage API tokens for your Atlassian account | Atlassian Support
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Prathap DL ,
I’ve just created the automation and I’ll be explaining it to you step by step. First of all, I want to mention that I like working with variables in automations, so I’ll be showing you the variables I created and what each of them does.
With this variable, I capture the project key.
customfield_11320
, which in my setup corresponds to my custom field. In your case, it will be the Document Number field. I increase this value by one so that it can be added to the newly created ticket.
Here I’m sharing an overview of the entire automation I explained above. I hope the explanation works well for you. Let me know if you have any questions.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pedro Olmo
I respectfully and strongly suggest not Creating Variable names with ones matching existing fields / smart values. That is likely to confuse people reading the rule and the rule logic.
For example, when there is an issue in scope, the rule could confuse {{issue.project}} and {{project}} (the variable) because when an issue is in scope, {{issue.project}} and {{project}} are the same thing.
One way to avoid this problem is to always and consistently add a prefix to variable names which is unlikely to collide. For example, using varProject rather than project.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Prathap DL
I don't know if it could help you but you can use the smartvalue increment in an automation to add +1 to a value.
Like this :
{{#increment}}4{{/}}
-> add 1 to 4 so in your customfield you could see 5
You can also reference a numeric field so it would be :
{{#increment}}{{issue.MyReferencedField}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.