Why is Behaviours script not triggered after inline edit?

I have written a Behaviours script that triggers and functions correctly when I use the Edit form and change the Due Date field.  However, when I do an inline edit of the Due Date field, the script does not seem to be triggered.  Any help would be appreciated.

import java.util.Date
import java.sql.Timestamp
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import org.apache.log4j.Logger
import org.apache.log4j.Level
Logger log = Logger.getLogger("com.tripadvisor.groovy")
log.setLevel(Level.DEBUG)
log.debug "BEHAVIOURS DUE DATE SCRIPT IS STARTING"
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
OptionsManager optionsManager = ComponentAccessor.getOptionsManager()
if (underlyingIssue != null)
{
    FormField dueDateFormField = getFieldById(fieldChanged)
    FormField isLateFormField = getFieldByName("Is Late")
    
    Timestamp originalDueDate = underlyingIssue.getDueDate()
    if (originalDueDate == (Object) null)
    {
        // log.debug "originalDueDate is null"        
    }
    else
    {
        log.debug "originalDueDate: " + originalDueDate
        Date now = new Date()
        log.debug "now: " + now
        int daysUntilDue = originalDueDate - now
        log.debug "daysUntilDue: " + daysUntilDue
        if (daysUntilDue < 1)
        {
            // Set Is Late custom field value to "Yes"
            CustomField isLateCustomField = customFieldManager.getCustomFieldObject(isLateFormField.getFieldId())
            FieldConfig isLateConfig = isLateCustomField.getRelevantConfig(getIssueContext())
            Options allIsLateOptions = optionsManager.getOptions(isLateConfig)
            Collection relevantIsLateOptions = allIsLateOptions.findAll { it.value == "Yes" }
            // log.debug "relevantIsLateOptions: " + relevantIsLateOptions
            Collection<String> isLateKeys = relevantIsLateOptions.collect { it.optionId.toString() } 
            isLateFormField.setFormValue(isLateKeys)
        }
    }
}
log.debug "BEHAVIOURS DUE DATE SCRIPT IS COMPLETE"

2 answers

Hi Neil,

Behaviours only works on the Create and Edit screens for an issue. Inside Newer versions of Script Runner then Inline editing is automatically disabled when a behaviour is added to a field.

For older versions as a workaround you can look to use JavaScript to disable in-line editing as described in the question here.

I hope this helps.

Thanks

Kristian

It seems (based on an old answer) that inline editing should be disabled for this field, but it is not.  I am using OS X 10.10.5 and Chrome Version 47.0.2526.106 (64-bit).  The same applies to Mac Firefox 42.0.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

176 views 0 4
Read article

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