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

@Ankur Bawiskar  I tried with bae64 -ignore true.it not worked let me try to give for all then.

 

Is the below format is fine?

(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 = " ";

//State validation starts......

if (ritmstate != '' && ritmstate != null && ritmstate != undefined) {
var stateval = new GlideRecord('sys_choice');
stateval.addQuery('name', 'sc_req_item');
stateval.addQuery('element', 'state');
stateval.addQuery('label', ritmstate);
stateval.query();
if (stateval.next()) {
stateid = stateval.value;
} else {

stateid = '';
}
}
//State validation ends........


//Error message update in staging table starts
else
{
//source.u_error_state = true;

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



if(ritmstate == 'Closed Complete' || ritmstate == 'Closed Incomplete' || ritmstate == 'Closed Skipped' || ritmstate == 'Cancelled')
{
ignore = true;
statemessage = "RITM cannot be created in " + ritmstate +" State.";
}

if(source.u_base64_data == "")

{
ignore = true;
statemessage = "RITM cannot be created.Missing Bae64data ";
errornote = statemessage;
source.u_error_reason = errornote;
}


if(source.u_filename === "")

{
ignore = true;
statemessage = "RITM cannot be created.Missing file name ";
errornote = statemessage;
source.u_error_reason = errornote;
}
if(source.u_content_type == "")

{
ignore = true;
statemessage = "RITM cannot be created.Missing content type ";
errornote = statemessage;
source.u_error_reason = errornote;
}
}
})(source, map, log, target);

yes looks fine.

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

@Ankur Bawiskar  No luck. Still same

did you check it went inside the if?

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

@Ankur Bawiskar No not went inside I guess

 

find_real_file.png
find_real_file.png