- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 07:20 AM
Hi, I am creating a scoped application for integration and have few transform maps. I want to run a transform map only if the target table exists. can we do that through scripting? thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2021 06:44 AM
Hi,
Glad to know that it worked.
Please use onStart transform script so that entire transformation is skipped if table not found
Also you should use ! operator in the gs.tableExists('table_name')
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(!gs.tableExists('table_name')) {
ignore = true;
log.info('Table not found so entire transformation is skipped');
}
})(source, map, log, target);
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
‎06-02-2021 08:45 AM
I have the defined table in my instance but when I move the app to some other instance it may not be there, since it comes with a plugin license. so in case it doesn't exists at least other transform maps will work fine. hence I want to put a condition on the existence of that table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 09:54 PM
Hi,
so that script line I shared should work fine.
Please give correct table name
Also try to run this script in background and check if it works fine
var table = new global.TableUtils("incident");
gs.info("Does 'my_table' exist? " + table.tableExists());
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
‎06-03-2021 12:15 AM
Hi Ankur,
thanks for the response
I did run the script in background and it fails with below error when using my custom scope. it works fine when I use the global scope in script background.
since this is a scoped application I will not be able to ask my customers to change the scope of the scripts include "TableUtils"
any alternatives?
"Illegal access to private script include TableUtils in scope rhino.global being called from scope <custom>"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2021 12:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2021 04:08 AM
Hi,
Doesn't work for me with or without global prefix. I tried changing the "Accessible from" for "TableUtils" script include to "all application scope" and it worked fine from my custom scope. it looks like "TableUtils" will be by default accessible only from global scope.
later I tried creating a cross scope privilege for this script include in my scoped app but even that does not work.
can I try something else?
thanks for spending time on my issue.