Transform Script Needed for empty source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:06 AM
Hi ,
I need a Transform script to ignore the empty data from the source file.
We are importing few data to Linux Server through excel sheet. We are seeing some blank record getting inserted every time. When i check the source staging table . I dont see any record contains empty .
Please let me know. How to ignoreif there is any empty data row getting inserted to cmdb_ci_linux_server table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:11 AM
Hi Shohaib,
Use the below script in an on before transform script
if (source.fieldName == ''){
ignore = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:12 AM
Hi,
You should write the script in Transform script and it should be 'onBefore' action.
if(source.u_field_name == ''){
ignore = true;
}
or
if(source.u_field_name .nil()){
ignore = true;
}
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:20 AM
Hi,
Already i have this script in Transform Map.
Is that will create a problem on creating the null values record . I put in place becuase . They told me to check below condition
1. If the excel sheet source and the solaris table contain data and if there is no data to update. It should update the Last discovery field
var sourceVM = source.u_vm.toString();
var gr = new GlideRecord('cmdb_ci_solaris_server');
gr.addQuery('name',sourceVM);
gr.query();
if(gr.next()){
target.last_discovered = new GlideDateTime();
target.update();
}else{
ignore=true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 06:50 AM
Hi,
I can see the requirement change above and now. Ok - If you are following importset table and updating the record with the same info then you should check the 'State' field in import set table. The state will show 'Ignored' and 'Comment' should show as 'No Fields Changed'.
This is OOB behavior. You should apply this 2 items as key factor in your 'If' condition and It should write under 'OnAfter' transform script.
I would recommend before writing the script, you should check mentioned actions and write the script.
Regards,
Suresh.
Suresh.