Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Runner Post-Function - Will not work correctly on on 'Create'

Tom
Contributor
October 30, 2019

Hi All,

Jira is making me want to blow my own brains out again....

Am using the below script to update a custom field with a given date.

This is a script runner post-funtion that when applied to any other workflow transition, works just fine, but when i apply it to the create transition;

The script runs and does not log any error but the field does not update the field.

Why does this work fine on one transition but not on another, i don't understand. :-(

-----------------------

//The below ScriptRunner post-function adds a specific number of days e.g. 365 to a custom field.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import java.sql.Timestamp

Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//define the dependent custom field
def dateACF = customFieldManager.getCustomFieldObjectByName("Forecast Date")

// Get today's date to s
def today = new Timestamp(new Date().time)

// build the new date
def dateB = today.plus(180)

//write back to custom field
issue.setCustomFieldValue(dateACF,dateB)

--------------------

 

1 answer

0 votes
Dharma Ramos
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2019

What order are you placing this in within the post functions?

Suggest an answer

Log in or Sign up to answer