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

This widget could not be displayed.

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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

425 views 3 17
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