Hello,
I am creating a behavior script using ScriptRunner and want to hide some field-based on selected value which is of an Insight object type.
For example:
if Native value(insight field) = XYZ then hide a field, if not XYZ =>do not hide the field.
This behavior is not working for me. Can someone please help?
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.component.ComponentAccessor
def log = Logger.getLogger(getClass())
log.setLevel(Level.DEBUG)
def monthlyMaintenance = getFieldByName("Is this for monthly network maintenance?");
//def tid = getFieldByName("TID and Business Service");
//============================
monthlyMaintenance.setHidden(true);
def tid_Insight = getFieldById("customfield_29540");
def tid_val = tid_Insight.getValue().toString();
def bs_Insight = getFieldById("customfield_29541");
def bs_val = bs_Insight.getValue().toString();
//============================
//ArrayList cascadeValueStore = tid.getValue() as ArrayList
//log.debug("cascadeValueStore----" + cascadeValueStore)
log.debug( "monthlyMaintenance----"+ monthlyMaintenance.getValue())
if (issueContext.projectObject.key == "ITPPM" && issueContext.issueType.name == "Change Log"
// && cascadeValueStore[0] =="INFR" && cascadeValueStore[1] == "Network"){
// && cascadeValueStore.contains("TO") && cascadeValueStore.contains("Systems Monitoring")){
// && tid_val.contains("IAT-1749431") && bs_val.contains("IAT-1806913")){
&& tid_val.contains("TO") && bs_val.contains("Systems Monitoring")){ // only show monthlyMaintenance field if this condition match
monthlyMaintenance.setHidden(false);
}
Behaviours formField.getValue() on an insight field will return either a single Object Key, or an Array of Object Keys depending on whether the field allows multiple or not.
So you can either get the key for the object that you want to trigger your behaviours and hard code that, or programmatically retrieve an ObjectBean from the Insight API then retreive the attribute values to use in the behaviour logic.
Thank you Peter. I am able to get the object value:
def tid_Insight = getFieldById("customfield_29540");
def tid_val = tid_Insight.getValue().toString();
But the behavior script is not able to capture events for Insight fields.
1. Selected customfield_29540 field which Insight field on behavior script screen
2. Implemented the above script.
3. Based on the value of customfield_29540 filed it should show/hide another field. This part is not working.
Please help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Newest versions of scriptrunner do fire behaviours scripts on insight field changes.
Though it doesn't yet from service desk portal screens.
Try to upgrade if you haven't in a while
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.