Conditionally skipping records in a Transform Map script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2009 04:04 PM
I am importing records from an Excel spread sheet. I need to be able to conditionally skip records. In my transform map script, I do something very similar to the following:
var incident = new GlideRecord("incident");
incident.addQuery("", source.field_name);
incident.query();
if (incident.next()) {
< populate target record here >
}
else {
skip input record
}
What I need to know is how to skip the record. I tried specifying ignore=true in the 'else' block, but then every input record was skipped. And if I don't specify ignore = true, then a large number of basically empty records were inserted into the database.
Anyone have any idea what to do here?
Thanks,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 12:02 PM
Anyone have any idea how to to this?Iam importing the passengers list from an excel sheet ,and i would like to create incidents only if the passengers region is 'USA'.
When i tried ignore=true,within the else condition it is creating an empty record instead of ignoring the specific record.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 12:23 PM
try making the choice action to ignore in the mapping of the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 02:57 PM
On transform map enable Run script and write script
if (source.u_passenger_region != 'USA'){
ignore = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2011 12:50 PM
I haven't used 'Field Map' in Table Transform Map .I do have the following script in the script section where i want to ignore the excel record where the passenger region is not USA.
var EmpNo = source.u_emp_no;
var Passenger = new GlideRecord('sys_user');
Passenger.addQuery('employee_number', EmpNo);
Passenger.query();
if(Passenger.next()){
if(Passenger.u_region == 'USA') {
target.caller_id = Passenger.sys_id;
var assignmentGroup = new GlideRecord("sys_user_group");
assignmentGroup.addQuery("name", "GSO Technology Support");
assignmentGroup.query();
if(assignmentGroup.next()) {
target.assignment_group = assignmentGroup.sys_id;
}
target.subcategory="International Travel";
target.short_description = source.u_routing;
}else{
ignore=true;
}
}