I've been testing some ScriptRunner functionality for our Jira Data Center environment, and have had no luck getting any Behaviours to trigger on field actions. For testing, I created a Behaviour for a test service desk (all issue types), added the 'Summary' Field to it, and attached a stripped down version of a test script to it:
def fieldToSet = getFieldByName('Description')
fieldToSet.setFormValue('The script has set this default value')
My understanding is that when the Summary value is updated, this should trigger the script in question. I've opened the request form on the customer portal, entered information, and submitted the ticket, and at no point did it set the value of the Description field. Checking the Behaviour, it still says the script has not run yet, and shows nothing in the execution history.
I feel like I'm missing something very fundamental in setting this up, but I don't see any other steps in any online tutorials. I'm on JSM 5.12.20, and ScriptRunner 8.44.0.
If anyone has any recommendations, or resources I might have missed, that would be much appreciated. Thanks!
I don't seem to be encountering any such problem on my instance.
Below is the sample working code that I have tested with:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import java.text.SimpleDateFormat
@BaseScript FieldBehaviours behaviours
def summary = getFieldById(fieldChanged)
def summaryValue = summary.value
def description = getFieldById('description')
def simpleDateFormat = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss')
def currentDate = new Date(System.currentTimeMillis())
if (!summaryValue) {
return
}
description.setFormValue("Summary Updated ${simpleDateFormat.format(currentDate)}")
Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.
Below is a screenshot of the Behaviour configuration:-
Note: The Behaviour configuration above is explicitly configured for a Service Desk / JSM project and not a Jira Software Project. Please ensure it is configured the same in your environment.
Below are a couple of test screenshots:-
1. When no value is set to the Summary, the Description field is empty.
2. Once a value is added to the Summary, the Description field is updated with a timestamp.
3. If the Summary is updated, once again, the timestamp in the Description field is updated accordingly as shown in the screenshot below:-
I hope this helps to answer your question. :)
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
After chatting with Adaptavist support, they helped me find what I was missing. When I first set up the Behaviour mapping, I had selected the 'mapping type' radio button for 'project/issue type mapping', and once I changed that to 'Service Desk mapping' it started working on the portal form.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the community. For Field Level Behavior, can you confirm that it is associated with the Summary field as a serveside script?
Lastly, does the Summary field update operation via the Jira UI (i.e. Edit action) or it is conducted from somewhere else?
Best, Joseph Chung Yin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
To the best of my knowledge, it's set up as a server-side script for the Summary field. I'll attach a screenshot of what I have.
I'm just going into the customer portal for the project, opening a new request, and filling in the fields there. Is there an extra step I need to take to have that trigger the Behaviour? I've been reading examples of how to set field default values based on other fields, which was the intention here - Summary is updated on the form, and Description then has its value set from the script.
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.