- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 09:30 AM
Our goal is to use a single transform map as a central point for multiple data sources to write to for our CMDB, but we have a requirement to also identify on the fly which data source made the call.
Is there anyway to do this that doesn't involve passing the data through the data source, which we can not do for certain sources?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 10:01 AM
The function getDataSourceName mentioned in the below scripts
Should be used in OnStart Scripts the following way
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var dataSourceName= getDataSourceName();
function getDataSourceName() // This function expects atleast one record in the Import set Table
{
source.next();
var dataSourceName = source.sys_import_set.data_source.name;
source.setLocation(-1);
return dataSourceName;
}
})(source, map, log, target);
If you want to use it in Onbefore Script, then use it the below way
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var dataSourceName= getDataSourceName();
function getDataSourceName()
{
var dataSourceName = source.sys_import_set.data_source.name;
return dataSourceName;
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 10:01 AM
The function getDataSourceName mentioned in the below scripts
Should be used in OnStart Scripts the following way
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var dataSourceName= getDataSourceName();
function getDataSourceName() // This function expects atleast one record in the Import set Table
{
source.next();
var dataSourceName = source.sys_import_set.data_source.name;
source.setLocation(-1);
return dataSourceName;
}
})(source, map, log, target);
If you want to use it in Onbefore Script, then use it the below way
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var dataSourceName= getDataSourceName();
function getDataSourceName()
{
var dataSourceName = source.sys_import_set.data_source.name;
return dataSourceName;
}
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 10:23 AM
Perfect! The solution works great. Note to anyone else who is having trouble, this returns 'undefined' if you do a test load. But load the data properly, and you'll get back the name of the data source!