Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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


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"...") 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( at com.atlassian.jira.issue.IssueImpl.setCustomFieldValue( at com.atlassian.jira.issue.MutableIssue$setCustomFieldValue$ Source) at

 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

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events