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

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

Post function (scriptrunner script) to set a current date value in custom field

Edited

Hi, I use script to set custom field on issue create:

import com.atlassian.jira.component.ComponentAccessor

import static java.lang.Math.*

import java.sql.Timestamp

def Begin_Date = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('custmofield_10200')

issue.setCustomFieldValue(Begin_Date, new Timestamp(new Date().time))

But its dont work, and I get error:

 The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2019-07-29 15:11:39,708 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2019-07-29 15:11:39,708 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: CR-20406, actionId: 1, file: <inline script> java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:896) at com.atlassian.jira.issue.IssueImpl.setCustomFieldValue(IssueImpl.java:906) at com.atlassian.jira.issue.MutableIssue$setCustomFieldValue$1.call(Unknown Source) at Script505.run(Script505.groovy:11)

 Help me please =)

1 answer

1 accepted

0 votes
Answer accepted

Hello @Владислав Яшин 

You are using setCustomFieldValue method on issue object, this is something which will not work.

Details as to what you should use are here

https://community.atlassian.com/t5/Jira-questions/How-to-write-a-number-customfield-in-a-transition-script-runner/qaq-p/1140145

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

776 views 17 21
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