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.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @VVC
what happens if you explicitly set 2025 as value? And what is the data Type of the attribute?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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.