Null values from fix script

Andre8
Giga Guru

I have a fix script to combine the data of 2 fields into 1. However, "null" is displayed for emoty values. Nedd help removing the null values

 

Andre8_0-1685538806683.pngAndre8_1-1685538863685.png

 

 

3 REPLIES 3

Prathamesh1
Giga Guru

Hi, 

Either use notNullQuery() to avoid null values in the first place. OR filter out the empty records and set their value as blank '' it will come as blank or (empty) for those records.

 

Hope it helps!

Please Mark Helpful/Correct if applicable.

Regards.

Andre8
Giga Guru

add the notNull() here?

 

var gr = new GlideRecord('x_1234_cdm_ext_organization');

gr.addNotNullQuery('u_address1');


gr.query();

while (gr.next()) {

var addy = gr.getValue('u_address1');
//addy = addy.trim();
var addy2 = gr.getValue('u_address2');

if (addy && addy2 > 1) {
gr.setValue('address', (addy + ',' + addy2));
gr.setWorkflow(false);
gr.update();
}

if (addy > 0 && addy2 == 0) {
gr.setValue('address', (addy));
gr.setWorkflow(false);
gr.update();
}
}

Prathamesh1
Giga Guru

Hi,

yes, correct. Using NotNullQuery will fix your new data.

To remove ( null, ) from the existing records. 

write this :

 

var gr = new GlideRecord('x_1234_cdm_ext_organization');
addEncodedQuery('u_addressLIKEnull,');
gr.query();

 

This will give you records containing 'null,' and you can change with correct value.

 

Please Mark helpful/correct if applicable.
Regards.