Any help would be appreciated with this.
I'm using script runner to prepopulate a field if the field is currently empty.
I have:
def value = getFieldByName('Acceptance Criteria').value
def field = getFieldByName('Acceptance Criteria')
to get the value of the field Acceptance Criteria
I should then be able to write:
if(value == null) {
field.setFormValue('Not Null')
}
But that's not working
To try and figure out why its not working I wrote this:
def value = getFieldByName('Acceptance Criteria').value
def field = getFieldByName('Description')
field.setFormValue(value)
if(value != null) {
field.setFormValue('Not Null')
}
So if the field Acceptance Criteria is not null the Description field would populate with "Not Null"
That works. Unfortunately it also populates Not Null when the Acceptance Critieria field is empty.
So even though the field is empty the system does not recognize it as null.
Anyone have any idea how to fix this?
I figured it out for anyone looking at this in the future.
I needed to change (value == null) to (value == '')
Apparently, null doesn't mean empty.
Hi Jeremy,
It is better to use Groovy Truth to do a null check as it is simpler:
if (!value) {
field.setFormValue('Null')
}
// or
if (value) {
field.setFormValue('Not Null')
}
Cheers,
Helmy
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.