Dear All,
I'm trying to write a simple Behaviour server script for my requirement.
I'm trying to keep a custom field Hidden/ disappear when the issue picker custom field has some value(Means if any issue linked) and the custom field should appear if there is no value entered in issue picker custom field.
def nrv = getFieldByName("IssuePickerField");
def r2=getFieldByName("FieldToBeHidden");
r2.setHidden(true);
r2.setRequired(false);
def rvcount = nrv.getValue();
if(rvcount == "")
{
r2.setHidden(false);
r2.setRequired(true);
}
I even tried to change if(rvcount == "") into if(rvcount == "NULL"), it doesn't work.
Please help me on how to get this working.
Thanks for your help!
Regards,
Mohan
Hi Mohan,
You can debug this to see the value in e.g. description:
def nrv = getFieldByName("IssuePickerField")
def nrvValue = nrv.getValue()
//Debugging
def desc = getFieldById('description')
desc.setFormValue(nrvValue)
And then trying to create/edit (or wherever the behaviour is set to work) you can see the value in the description in real time.
However if I get this right, if nrv is a multiple issue picker, it should contain either a single username (in behaviours likely auto-converted to String class), or a collection [username1, username2]
So depending on what value and class this returns (and you should try both a single and multiple values to be sure), you can better structure the if blocks.
I would guess it will be similar to
def nrv = getFieldByName("IssuePickerField")
def nrvValue = nrv.getValue()
if (nrvValue.size() == 0) {
//do something
}
else {
//something else
}
Didn't check that but fairly sure it will be similar - I like debugging with the returned values/classes via some ad hoc text-field (description) since that gives you the best visibility to what you're dealing with.
Regards,
Radek
Dear @Radek Dostál , thank you for the information and detailed explanation. I will test it and see if it works!
Appreciate your response :) Stay Safe.
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.