Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner - How to update current date on custom field using on post fucntion

Hi, 

I would like to know the Custom script post-function allows to update a custom date field (dd/mm/yyyy) with the current transition date. 

I have tried few codes but non of them works.

using ScriptRunner 5.1.6

 

Thanks in advance.

2 answers

1 accepted

2 votes
Answer accepted

Problem solved. 

i used this script : 

import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dateCf = customFieldManager.getCustomFieldObject("customfield_12345") // Date time fields require a Timestamp
issue.setCustomFieldValue(dateCf, new Timestamp((new Date()).time))

thanks for this document: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html

Hello @Raphael Israel KLEIN ,

 

This worked for me - thank you very much.

 

Regards,

Rahul Savaikar

2 votes

Without knowing what you've tried, it's quite likely someone will give you the code you've already used.

Could you tell us what you've tried?

hi, i had some weird behavior (could not create new Timestamp) but seems like today it is working better... not sure what i did wrong. 

Thanks 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you