- 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 03:35 AM
then you should write
code like
if(serviceoffering is not present condition)
ignore=true;
varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 03:36 AM
Hi Manikandan,
for this you need to write transform script onBefore
query service offering table with the incoming value;
a) if found then do query on company table;
1) if company found update;
2) if not found insert
b) if not found the service offering use ignore = true and entire row would be ignored
I believe you are running data source on company table here
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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:05 AM
Hi,
Sorry i am new to scripting. I just need that record to be skipped when the service offering does not exist.
is my below code 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('cmdb_ci_vm_instance');
if( ci.next()){
ci.addquery(ci.u_offer_name,source.u_bci_peer_name);
ignore = true;
}
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2019 04:25 AM
var ci = new glideRecord('Service offering table');
ci.query();
var ci_offer = ci.u_offer_name;
while(ci.next()){
if(ci_offer= = source.u_bci_peer_name){
ignore = true;
}
}
Thanks,
Rahul Kumar