Hi Folks,
I have Custom field Source ID(Text field) values contains like KB-*,IN-*,TE-*..etc, Now i have to create behavior script If Source ID values starts with KB* i want to make RCA Custom field(text field) Required.
Tried below script but not working. Script-1
-------------------------------------------------
Hi @jaya chandra reddy nellore
you could try changing the first script as follow:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def Source = getFieldByName('Source ID').formValue
def RCAfield = getFieldByName('RCA')
if(Source.toString().contains('KB') ) {
RCAfield.setRequired(true)
} else {
RCAfield.setRequired(false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @jaya chandra reddy nellore ,
welcome to the Atlassian community!
Here a correct behaviour code to associate to your field Source ID.
def sourcefield= getFieldByName('Source ID')
def RCAfield= getFieldByName('RCA')
String sourceValue = sourcefield.getValue()
if(sourceValue.startsWith("KB")){
RCAfield.setRequired(true);
} else {
RCAfield.setRequired(false);
}
Please let me know if it works,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Fabio Racobaldo _Herzum_ This is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need to add that code in a behaviour mapped to your project/issue type and for field "Source ID". It should work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Fabio Racobaldo _Herzum_ Please check below screen shorts, i am also following same but no use.
behavior script: Screen shorts 1 & 2
Checking behavior applied or not: Screen shorts 3 & 4
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.
please could you share me a screenshot of transition screen with both values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @jaya chandra reddy nellore,
If you are using this for a Server-Side Behaviour, the correct approach to ensure that the Behaviour will be triggered is to use the fieldChanged to initialise the field the Behaviour is configured for, as shown below:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def Source= getFieldById(fieldChanged)
def sourceValue = Source.toString()
def RCAfield= getFieldByName('RCA')
RCAfield.required = false
if(sourceValue.contains('KB') || sourceValue.startsWith('KB') ) {
RCAfield.required = true
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Without going in to details already, I notice you use different methods for setting required.
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.