- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 03:26 AM
Hi,
I have 2 tables, Service Offering and company. Company table has a reference field referencing Service Offering table. When i do a data import to the company table, if the serivce offering does not exist in the service offering table then it creates an entry in the Service offering table. The requirement is if the Service offering value does not exist in the Service Offering table then the transform map should fail and the data import should not happen to company table.
How do i achieve this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:56 AM
Hi Manikandan,
Open the field map and set action reject.
2. If you would like to ignore entire row , write onBefore transform script .
var serviceOffering = source.getValue("please give service offering var name");
if (action == ïnsert && JSUtil.notNil(serviceOffering)) {
var serviceOfferinGr = new GlideRecord("ServiceOffering table name");
serviceOfferinGr.addQuery("Please give variable name which you would like to compare from service offering table", serviceOffering);
serviceOfferinGr.setLimit(1);
serviceOfferinGr.query();
if (!serviceOfferinGr.next()) {
ignore = true;
}
}
Regards,
Harish Murikinati.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:14 AM
Sorry Modified the script a bit. Could you check if this script is correct?
if (action == "insert" ) {target. setNewGuid (source. u_sys_id ) ; }
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var ci = new glideRecord('Service offering table');
ci.query();
var ci_offer = ci.u_offer_name; //setting the field "Name" which is the display value in Service offering table to a variable
if(ci.next()){
ci_offer = source.u_bci_peer_name; //checking if the service offering name = Service offering field in transform map
ignore = true; //ignoring that record if it is true
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:18 AM
Hi Manikandan,
The script seems to be incomplete.
you need to get value of service offering from source object which is the import set table; then query service offering table
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-19-2019 04:23 AM
ci_offer = source.u_bci_peer_name;
The above query extracts the Service offering name from the source. Sorry u_bci_peer_name is the display name of Service offering in source table.
Will this script work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:28 AM
// Add your code here
var ci = new glideRecord('Service offering table name');
ci.addQuery('field name from this table(ci_offer)',source.u_bci_peer_name);
ci.query();
gs.log(ci.getRowCount()+"no of record");
if(ci.next()){
ignore = true; //ignoring that record if it is true
}
please add your table name and field name in code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:41 AM
Hi Varsha,
this script is ignoring only the Service offering field. But my requirement is if the service offering is not existing then the company data should not load at all for that row 😞