What is the Null value for "Issue Picker" in Groovy?

Mohan Sundar July 13, 2020

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

1 answer

1 vote
Radek Dostál
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.
July 13, 2020

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

Mohan Sundar July 13, 2020

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.

Suggest an answer

Log in or Sign up to answer