Null values from fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 06:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 06:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2023 07:27 AM
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 02:46 AM - edited 06-01-2023 02:54 AM
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.