Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Dynamic field validation in Transition screen

Akbar N November 6, 2018

Hi, 

I want a field in Transition screen to be marked as Mandatory based on the value in Issue create screen. I have implemented this using Behavior add on the Create screen but the same is not working on the Transition screen. 

Say choosing 'No' to a custom select field 'Are You using Rally' in create Issue screen need to make a field in Transition screen as mandatory. Kindly note i'm not going to display 'Are You using Rally' again in Transition screen for this purpose. 

I have this code working without any issues in create issue screen. I have place this code under validator section of the Transition screen as Script validator. Any idea why it is not working in Transition screen.  

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def compReviewSelectCf = getFieldById("customfield_18620") // parent filed
def vpCompJustSelectCf = getFieldById("customfield_18805") //child field.

if (compReviewSelectCf.getValue() == "Compliance Approval Not Needed"){
vpCompJustSelectCf.setRequired(true);
}

 

1 answer

0 votes
Joshua Yamdogo @ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

Hi Akbar,

The field would need to be on the screen for the behaviour to work. You could try setting up a Simple Scripted Validator on your workflow transition instead. See this page: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html

Regards,

Josh

Akbar N November 11, 2018

Hi Joshua, 

I have done the following but still no luck. 

1. I have put the parent field in the transition screen itself. 

2. Used Simple scripted validator to trigger the mandatory validation

 

There is no change happening and validation is not triggering on change of parent field. Any idea? Also the setRequired and setVisible is also not working. 

Suggest an answer

Log in or Sign up to answer