- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 11:45 AM
Hi,
I am trying to load data and run a transform map to load them to target table. My requirement is if I try loading the data which I am not expecting then it should just ignore the record and update the remaining records.
Sample Data is as below.
I am trying to run a onBefore Script and checking for the Number which will always start with certain prefix like INC or SINC and ignore SrINC records. Below is the code which I am using when I run the transform map.
var str = source.u_number;
var incregex = /^INC/;
var sniregex = /^SINC/;
if(!incregex.test(str) || !sniregex.test(str)){
ignore = true;
}
Any help on this is very much appriciated.
Thank you in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 01:51 PM
Try this
It should work - onBefore transform map script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var str = source.u_number;
str = str.replace(/[0-9]/g, ''); //replace all numeric part
if((str == 'INC' || str == 'SINC') && (action == 'insert' || action == 'update'))
{
}
else
{
ignore=true;
}
})(source, map, log, target);
Let me know then if you need any further help
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 10:54 AM
Thanks Anshu that helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 04:14 PM
Hi ursnani,
You can use the following script;
var str = source.u_number.toString();
if(str.search(/INC[0-9]/i) != 0 && str.search(/SINC[0-9]/i) != 0)
ignore = true;
Hopefully this will resolve your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2022 11:20 PM
Since ServiceNow recommends to start using robust transform map where possible vs transform map, in order to implement ignore functionality