Transform Map onAfter Script check for target field is null

anfield
Tera Guru

Running an onafter transform script and trying in one function to only populate a reference field on an existing record if it is null (there is other code above that function that sets the field). What is the correct way to do this in an onafter script?

For example

if (target.field. == ' ' ){

then do something

}

4 REPLIES 4

Mike Allen
Mega Sage

You have an extra dot on the end of field.  That might be a transposition error.

You can try target.field.nil(), or !target.field.hasValue(), but target.field == '' should work.

That was a typo. Thanks. Also quick question how can i reference undefined, is it undefined or 'undefined' in quotes?

In the system OOB, there is both:

if (choice.sys_id != undefined) {

and

if(typeof field != 'undefined') {

So, it looks as though if you are directly referencing the result, it is without ticks, but if you are looking at the type of the field, it is with ticks.

ARG645
Tera Guru

Something like this will act strong.

if(JSUtil.nil(target.getValue('field'))){
   // then do something
}