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"
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.