Hi - I am very new to Jira. I am trying to create an automation that will update a field on my issue. I will attempt to explain, using generic capitalized field names:
In the NAME field, I want to concatenate values from the REGION, TYPE and DATE fields.
I want to reformat a value selected in the TYPE field and in the DATE field as part of the final concatenated value in the NAME field.
For example:
In the NAME field, I want to concatenate: REGION-TYPE-DATE
A final example of the value format in the NAME field would be: NAM-A-20221023
What syntax do I use in the NAME field to produce these results?
Hi @sarah.wight ,
You can try edit field action with smart values like below
{
"fields": {
"Your Field Name": "{{issue.your_region_field}}-{{issue.your_type_field.substringAfter(\"Type \")}}-{{issue.your_date_field.format(\"YYYYMMDD\")}}"
}
}
To find your field in smart value, access Filters > Advanced issue search > Switch to JQL (if you're in basic mode) > type your field name.
If it contains cf[10xxx] then your field in smart value should be customfield_10xxx.
You can find more text field functions here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/
Date field functions here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/
Hope this helps!
Thanks @Thuan_ Do Dang - I'm doing something wrong but I don't know what. Here is my syntax:
{{issue.Region}}-{{issue.customfield_12258.substringBefore("-")}}-{{issue.startDate.format("YYYYMMDD")}}--{{issue.Summary}}
It is populating this:
GL----Summary value
It was very difficult to find the custom field ID - what you suggested did not show it. I had to Inspect the page and search for it that way. But I found it and changed to substringBefore (instead of After, as you showed, because my example was not exactly how I had each value formatted in reality).
I am not sure how to write the Smart Value for the system field "Start date". I have tried entering an underscore between the words, leaving a space, and putting them together as you see above but nothing is being produced.
Regardless, my attempt is only showing the Region and Summary field values. It is not populating the custom field and date values between those two.
What did I do wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sarah.wight ,
Because of your syntax inside "", if you have other ", it should be \"
{{issue.Region}}-{{issue.customfield_12258.substringBefore(\"-\")}}-{{issue.startDate.format(\"YYYYMMDD\")}}--{{issue.Summary}}
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope, this did not work. I have no idea why. I feel like there is just something simple missing here. The Region and Summary values are the only ones populating.
Is there anything else I can try or should I troubleshoot some other way?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sarah.wight ,
I'm sorry for my mistake. Here is the updated syntax
{{issue.Region}}-{{issue.customfield_12258.value.substringBefore("-")}}-{{issue.Start date.format("YYYYMMdd")}}--{{issue.Summary}}
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thuan_ Do Dang - This has gotten me closer!
{{issue.Region}}-{{issue.customfield_12258.value.substringBefore("-")}}-{{issue.Start date.format("YYYYMMdd")}}--{{issue.Summary}}
Now produces:
GL-TD---My Show
I don't know what is wrong with the date field and/or format syntax but it just will not populate anything. In my research, I have found that this format of date is called "BASIC_ISO_DATE". How can I reference that? Anything else I can try to get the date in that format? Am I referencing a field that cannot be used int his way - Start date?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sarah.wight ,
The syntax of date above is a right syntax, it works on my instance. However, we can try other way, using 'customfield_10xxx' instead of 'Start date'.
Please go to Settings icon next to your avatar > Issues > Custom fields > search your date field (make sure your date field type is Date picker or Date time picker) > click ... at the end of a field > select View field information/Edit field > look at your URL, you can see your custom field id there.
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Thuan_ Do Dang & @Bill Sheboy - I found this article: https://community.atlassian.com/t5/Jira-Software-questions/What-is-the-smart-value-for-my-custom-start-date-field/qaq-p/1793650
...and viewed all of the fields on my issue to see if there was a custom field ID for the "Start date" field, which I had assumed (ah hah!) was a system field, not a custom field. Apparently, it is a custom field? Either that or every field actually has a custom ID????
Anywho, I found the custom field ID for "Start date", popped it in to my concatenated string, and after approximately 40 hours of researching, trial and error, headaches, complaining to my husband and colleagues, and working with you both: IT WORKED.
{{issue.Region}}-{{issue.customfield_12258.value.substringBefore("-")}}-{{issue.customfield_12007.format("YYYYMMdd")}}--{{issue.Summary}}
Aside from the excessive development time spent on this, I would be happy with this final result save one small detail: "Region" is actually a custom field and I know that for a fact because I made it. So, for consistency's sake, why - WHY do I NOT need a custom field ID there, but I DO for Campaign Type and Start date? Please tell me there is a legitimate reason and I'm not just taking crazy pills. THANK YOU
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sarah.wight
First thing, I am going to assume your fields are not actually named TYPE and DATE, as that could cause both confusion and potential problems for your site admin. If those are the names, consider changing the names to better match their meaning. I am also assuming that REGION and TYPE are single-select field types.
Next, for a question like this context is important; please consider posting an image of your complete rule as that will help the community see the same thing as what you are observing.
As you have described your use case, please try pasting this smart value into the edit for the NAME field. There is no need to use the advanced JSON edit.
{{issue.REGION.value.concat("-").concat(issue.TYPE.value).concat("-").concat(issue.DATE.format("YYYYMMDD"))}}
After you paste it in, the smart value will appear below the field, and you can then select it to use in the edit action.
To learn more about the concat() function, please look here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#concat-String-str-
To learn about the date/time formatting, please look here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#--
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.
Hi Bill - Thanks for sharing that information about concatenating and date formatting.
My main problem is the examples given on these pages do not paint an entire picture for someone who is not a developer by trade but needs to do some of this work. I'm not saying rewrite everything; I am saying a few small changes would have helped me a great deal. For example - in the examples:
Now back to my use case, which I didn't think I would have to post true details of. I get the "we need context" suggestion but I admit, I thought my question and need was simple. I didn't think I had to go that far. Here are all of the juicy details:
I have an automation, where upon an issue being created, I want to concatenate values from 4 different fields - some custom, some standard - into a separate custom field:
Now here's the rub - for 2 of the 4 fields in my concatenation, I want to format the values. Here are all of the fields I want to concatenate:
The field I want to place this concatenation into is a custom field called "Campaign Name".
I won't confuse you with the 50 ways I've tried to write the syntax for this concatenation. The most I was able to produce was the Region and the Summary values, but none of the formatted values for the Campaign Type or Start date fields appear.
Can anyone, now with this context, tell me how to properly syntax the concatenation of these 4 fields?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What happened when you tried the smart value expression I provided, as I believe that matches what you asked to do?
I can understand and empathize with your comments about the documentation for automation rules. It continues to improve, and it still needs improvements. When I find a particularly confusing documentation page, I select the "Provide feedback about this article" to give Atlassian feedback.
Regarding custom field names and the resulting smart values: as admins can change the names of fields as they wish, the spacing and capitalization can be impacted for the smart value. This particularly happens when customers use non-alphanumeric characters in the field names. When the field is supported, the custom field ID value should work if you are unable to determine the smart value based on the field name.
I also agree that for simple use cases, automation rules are straightforward to create and use. For more complicated needs, often experimentation is required to get the syntax to work as desired. I good approach is to create a simple rule in a test project, often writing to the audit log to confirm results. Once your rule is ready then copy it to the desired project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill - When I used the smart value expression you provided, it gave me the region value and the type value, but not the date value.
Of course the type value was not the format I needed, but regardless the entire concatenation did not appear.
There must be something wrong with the way I am referencing the standard field "Start date" in the expression, because even without my preferred format for Start date, nothing is being returned. Does it need to be Start_date? Start_Date? startDate? Startdate? Something else entirely? It is not a custom field, so that is not a possibility.
But once I figure that out, how do I format the Start date as YYYYMMDD? Also known as BASIC_ISO_DATE, as I discovered.
I appreciate all of the help I've received so far. See Thuan's responses below. His help has gotten me the furthest to my goal, with the Start date value and format missing there as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Sarah!
Something I find helpful to build up a concatenated string like this is to first write the pieces, one by one, to the audit log. When I get formatting correct, I then start combining them to confirm the results.
If you are using the built-in Start Date field, the smart value would be
{{issue.Start date.format("YYYYMMDD")}}
For the Campaign Type, you may need to pull that apart with the following. Please adjust to match your field name's smart value.
{{issue.Campaign type.substringBefore("-").trim()}}
And I completely agree with you on the confusion for "when does a smart value work as the field name versus only the custom field id"? I hypothesize there is something internally that collides with customer-chosen field names...they we (customers) cannot see that collision. The only way to be certain is that how-to from Atlassian on calling the REST API to find the supported smart values.
And even then...not all custom fields work with all functions! So when in doubt, write to the audit log first to confirm the pieces before rolling stuff up into a complex expression.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.