Update and show message in Transform map

suryan
Kilo Expert

I have a transform Map in which I had made field(ST_ID is the field name) as Coalesce, so that only matching records gets updated when user export the excel file and updates it.

I want the transform map not to update or stop updating, when a specific field(ST_Validation_ID) has 'no records' / blank, show the error message about it while transform.

Below is the transform map script :

if(source.ST_Validation_ID == ''){

error= true;

error_message = 'Validation ID is empty.';

}

if(action == 'insert'){

ignore = true;

}

i add log statements in 1, 2, and 5th line but it is not showing any message.

Regards,

Surya

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi Surya



the following is what the documentation states regarding logging in transform maps:



The log object for the current import run. Use this object to log messages such as log.info("<Message>") or log.warn("<Message>"). This object logs to the import log for standard import sets, or other log locations as required, such as for web service imports.


source: http://wiki.servicenow.com/index.php?title=Creating_New_Transform_Maps#gsc.tab=0



Thanks,


Berny


View solution in original post

9 REPLIES 9

Btw... where you checking to see if you're getting the message? Are you checking the system logs?



At the navigation window is at System Logs >> System log >>   ALL



I believe that a gs.log("the message"); will also work.



Thanks,


Berny


Below is screen shot showing system log error:



This is the code i wrote in transform map:



find_real_file.png



(function transformRow(source, target, map, log, isUpdate) {



log.info("1");



gs.log("NF onBefore Script Called");


gs.log("NF source.u_supplier_validation_result is:"+source.ST_Validation_ID =);



log.info("2");


if(source.ST_Validation_ID == ''){


error=true;


error_message='Validation ID is empty.';


}



find_real_file.png


Hi Berny,



I checked for every condition it is working fine


sorry small change in my question:



1)I'am updating 1000 records if 990 records is having ST.validation_ID, then i don't want to update single record in transform map,(the transform map should not be happen for single record out of 1000 i.e if 1 record is missing validation.ID whole 1000 records should not update.)



2)I'am getting messages in system log, is it possible to get the message while doing transform map so that user be able to know that records are not updating because of empty validation ID.


Hi Surya,



For 1) you can abort the entire import/transform process within an onStart script. You set the ignore value to true within the onStart script



https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference...



For 2) I don't believe that's possible. You could try using a gs.addInfoMessage



Thanks,


Berny


suryan
Kilo Expert

Hi Berny,



This is the script. I want to abort the whole transform if any one record has ST.validation_ID = ''.


I tried uploading 10 records, out of that i made 8th record has ST.validation_ID = '', but still it is updating 9 records except that 8th record which has ST.validation_ID =''. I want whole transform not to update if any one has ST.validation_ID=''



(function transformRow(source, target, map, log, isUpdate) {



if(source.ST_Validation_ID == ''){


ignore =true;


error=true;


error_message='Validation ID is empty.';


}