how to validate empty data in transform map?

jobin1
Tera Expert

Hi All,

 

I need to validate below excel data while doing transform load (before loading to table)

Validation should be like if the bae64 data is empty then it should not allow to load data.

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@jobin 

you can use onbefore transform script

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here
	if(source.u_base64_data.nil())
		ignore = true;

})(source, map, log, target);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

20 REPLIES 20

alert is client side and your script is server side

so please use gs.info() to check logs

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  gs.info() also used but not getting inside

the logic is correct

try to debug further

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  Below code is working and I have removed few validation now bae64 and file name validation only in place.

find_real_file.png

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

var cat_num = source.u_number;
var cat_item = source.u_item;
var fname = source.u_filename;
var ritmstate = source.u_state;
var contenttype = source.u_content_type;
var bae64 = source.u_base64_data;


//Source table map - ends here...

 

var category1,sub_category1,subcategory22,user_id,username,country,company,phone,assignment_group,company_sysid,asigntosysid,stateid,openstateid,rescatgsysid,clscode,urgcyvalue;
var errornote = " ";


var invaliderror = "";
var mandatoryerror = "";
var invalidmessage = "";
var statemessage = "";
var mandmessage = "";





if(source.u_base64_data == "")

{
ignore = true;

statemessage = "Missing Bae64data ";
errornote = statemessage;
source.u_error_reason = errornote;
}


if(source.u_file_name == "")

{
ignore = true;
statemessage = "Missing file name ";
errornote = statemessage;
source.u_error_reason = errornote;
}
//}
})(source, map, log, target);

@jobin 

Glad to know that it worked.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader