How do I set a custom field with the current date/time in a post function?

I'm trying to create bulletins in our wiki and have the creation date along with the updated date appear in a heading (I'm going to make a template). The bulletin name will include the date stamp.

How can I accomplish this?

Thanks leon

2 answers

0 votes
Alexey Matveev Community Champion Dec 14, 2017
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Date
import java.sql.Timestamp
import java.util.Calendar
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue


def csDateTime = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Date Time Picker")


Calendar currenttime = Calendar.getInstance();
Timestamp csNewDateValue = new Timestamp((currenttime.getTime()).getTime());
csDateTime.updateValue(null, issue, new ModifiedValue("", (Object) csNewDateValue), new DefaultIssueChangeHolder())

GM ok this is my first attempt at these things. Here's what I want to do I want to display the created date one place, then the last updated date in a different place.

I'm assuming this is a user macro? Newbie here so please accept my apologies in advance.

thanks leon

I found a preexisting macro called Builder Info that does what I need.

What I would like to do next is take the creator date and add three months to it and then display that as a review date.

 

thanks leon

i found one other item. this is being crafted into a "template" so the created date is the date the template was created not when it was copied/saved as a new item. Anyway we can get around this?

thanks so much leon

ok i just tested and if I make a copy of the template and save it off the creator date reflects when it was saved so that is good. so now only need to figure out how to add a certain number days/months to the creator date for the review date

how can i manipulate the variable(s) from BuilderInfo so I can add a fixed number (like 90 days) to that variable and then display it?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,180 views 20 14
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you