Forums

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

How to create label from date format field

Radka Svobodova
Contributor
August 28, 2025

Hi,

I would like to create a custom label field value (number) from custom field date type (end date) as a month only by automation rule, f.e. from "MM/DD/YYYY" I need the label to be "MM", how to get a correct json?

Thanks for help,

Radka

3 answers

1 vote
Bill Sheboy
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.
August 28, 2025

Hi @Radka Svobodova 

Context is important for automation rule questions.  Please post images of the following:

  • your entire rule in one single image for continuity
  • the action where you are trying to add the label
  • the audit log details showing the rule execution

Until we see those...

 

You describe getting errors for invalid JSON, but in some cases shown you are not using any JSON which could cause that.  Assuming you are using JSON in the additional fields / advanced edit...

You are trying to create a label, and that uses this JSON formatting, changing to use your custom field ID:

{
"update": {
"customfield_12345": [
{
"add": "my-new-label"
}
]
}
}

And, the new label you are trying to add uses the format() function, which includes quotation marks.  As a result, that would nest the quotation marks, leading to invalid JSON.

The expression could instead add the asJsonString function at the end to eliminate the need for the surrounding quotation marks:

{
"update": {
"customfield_12345": [
{
"add": {{issue.customfield_10081.format("MM").asJsonString}}
}
]
}
}

 

Kind regards,
Bill

1 vote
Akriti Sagar
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.
August 28, 2025

Hi @Radka Svobodova,

You can achieve this in Jira Automation by using smart values and a date formatting function. If your custom date field is called End date, you can extract just the month and set it into a label/number field.

For example, in your Edit issue → Labels (or number field) action, use:
{{issue.customfield_XXXXX.format("MM")}}

Where:

  • Replace customfield_XXXXX with the actual field ID of your End date field.

  • format("MM") returns the month number (01 to 12).

  • If you need the short month name (e.g. Jan), use format("MMM").

  • For full month name, use format("MMMM").

So if End date = 08/28/2025, the smart value {{issue.customfield_XXXXX.format("MM")}} will give 08.

To find your field ID, go to Automation → Audit log after running the rule once and expand the “View issue data” section—it will show the exact smart value name.



Radka Svobodova
Contributor
August 28, 2025
Hi, I actually tried that, and it still gives me not valid jsonScreenshot 2025-08-28 at 10.51.43.png
I tried also
{
"update": {
        "month label": [{
                "add": {{issue.customfield_10081.format("MM")}}
        }]
    }
}
and thats is not valid json too, a some how need a transform the value MM to the string, but what I have tried yet did not work.
Bill Sheboy
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.
August 28, 2025

Hi @Akriti Sagar 

What is the source of the content you posted?

As a reminder, when posting bot / AI-generated content, the source should be disclosed in the post's text.  For more information, please see the Community Guidelines:

https://community.atlassian.com/forums/custom/page/page-id/rules-of-engagement

 

Kind regards,
Bill

0 votes
Benjamin Črnjak
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.
August 28, 2025

Hi @Radka Svobodova ,

 

you could use smart value for Date format {{[date].[dateformat]}}

replace [date] with a smart value/variable of the input date you want to format, and for date format use: format("MM").

So let's say you have a date field called MyDate (example: customfield_1234), it would look something like this:

{{issue.customfield_1234.format("MM")}}

regards,

Benjamin

Radka Svobodova
Contributor
August 28, 2025

Hi, I actually tried that, and it still gives me not valid jsonScreenshot 2025-08-28 at 10.51.43.png

I guess I need mor to transform it to string to add to label type field

Benjamin Črnjak
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.
August 28, 2025

I suggest you to use log actions so you can check what results are you getting from different smart values.

At the end, there should be no problem editing label field with the new value.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events