Forums

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

In Jira Data Center asset management, set the default value to a text attribute type

VVC
Contributor
July 11, 2025

How to automatically set the text attribute type to a default value "2025" or most preferably a dynamic value of the current year at the time of object creation in Jira Data Center asset management?

I have an asset automation that concatenates three attributes and updates the object after creation. One of the attribute includes "ReportYear" of type text and it should default to current year each time. Please suggest a resolution if this is feasible to achieve in asset management automation.

 

1 answer

1 vote
Hari Krishna
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 11, 2025

Hi,

If you're using Jira Data Center and working with Assets, and you want to automatically fill a text field like "ReportYear" with the current year when an object is created, there’s a simple way to do it using asset automation.

Just follow these steps:

 

Go to your Assets schema and open the Automation tab

 

Create a new rule with trigger as Object Created

 

Add a condition if needed (like only for a certain object type)

 

Add an action → Edit Object

 

In the edit action, pick the "ReportYear" attribute and set the value like this:

 

{{now.format("yyyy")}}

 

That smart value will always give the current year — so if someone creates an object in 2025, it sets "2025", in 2026, it'll be "2026" — fully dynamic.

 

Just make sure the ReportYear field is left blank during creation (don’t make it required), so that automation can fill it in right after the object is created.

 

That’s all. Once set, the rule will handle it on its own without any manual input.

Stefan Stadler
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.
July 11, 2025

perfect answer. If it needs to be more complex, you could also run Groovy scripts on certain events. The triggers are the same, just the action needs to be "Execute Groovy Script" and setting up the script is a little complex.

See here for details, also on Hari's answer:

Configuring Assets automation rules | Atlassian Support | Atlassian Documentation

Like John Funk likes this
VVC
Contributor
July 11, 2025

Hi @Hari Krishna and @Stefan Stadler I do not see Edit Object action in the automations under Object Schema configuration  in Jira Data Center on-prem 9.12.x release. Do you see this option in your instance?2025-07-11_13-51-26.jpg

 Also, I have already tried the following automation options but it still could not setup the default value for the text attribute.

 

Groovy script asset automation #1
def object = event.object
if (object.objectType.name == "Cognos") {
    object.setAttribute("ReportYear", "2025")
    object.store()
}
Groovy script asset automation #2 - 
return String.valueOf(java.time.Year.now().getValue())

Automation #3-
Action = Attribute Value
Attribute Name = ReportYear
Value = 2025

Like John Funk likes this
Stefan Stadler
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.
July 11, 2025

Attribute value is the selection you have to take.

Select "Attribute value", specify "ReportYear" as the attribute name and use the smart value in the value section.

Like John Funk likes this
VVC
Contributor
July 11, 2025

Unfortunately, this is still NOT working, as the Report Year attribute is empty before and after the object creation.

2025-07-11_14-11-15.jpg

Like John Funk likes this
Stefan Stadler
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.
July 11, 2025

Hi @VVC 

what happens if you explicitly set 2025 as value? And what is the data Type of the attribute?

Hari Krishna
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 11, 2025

Hi,

Yes, that's correct — in Jira Data Center 9.12.x, the "Edit Object" action isn’t available in Assets Automation yet. To dynamically set the "ReportYear" field (Text type) during object creation, you can use the "Execute Groovy Script" action instead.

Here’s a working script that sets the current year:

import java.time.Year

def object = event.getObject()
if (object.objectType.name == "Cognos") {
def currentYear = Year.now().toString()
def attrBean = objectType.getObjectTypeAttributeBean("ReportYear")
object.setAttribute(attrBean.getId(), currentYear)
object.store()
}

Make sure:
- "ReportYear" is of type Text
- It’s not marked as required (so the automation can populate it)
- You use this script in an "Object Created" trigger

Tested on 9.12.1 and it worked well. Let me know if it helps!

Suggest an answer

Log in or Sign up to answer