- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 04:29 AM
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.
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 05:48 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 04:35 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 04:55 AM
yes looks fine.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 05:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:17 AM
did you check it went inside the if?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:43 AM