Changing Transform map action at run time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2012 02:22 AM
I am trying to implement a transform map on "cmdb_ci_server" table (target table is "cmdb_ci_server"). I have some entries created in "cmdb_ci" table.
While running transform map on "cmdb_ci_server" table on Transform map script I am checking if the record with same name exist in the "cmdb_ci" if exist I want to change the action of the transform map. I am trying to achieve it with below line of code in transform map "Run Script".
action = 'update';
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', 'testServer.001');
gr.query();
if (gr.next())
{
target.sys_id = gr.sys_id;
}
so that even though the previous action was insert Record will update the existing record from cmdb_ci table.
Some how even after setting these values, I can see 2 entries created in the data base.
Or is there anyway, I can update the class of the record before transform map 'action' is decided ?
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- 1,818 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2012 05:30 AM
I believe you can do this with an onBefore transform map script. Check out the transform events here:
http://wiki.service-now.com/index.php?title=Transform_Map_Scripts#Transformation_Events
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2012 07:53 AM
Thanks Ivan, but that doesn't work.
If the 'action' of transform map is 'insert' it doesn't change the behavior of it. The transform map inserts new entry in cmdb_ci table. Is there any other way I can change the action on the fly?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2012 08:30 AM
You would most likely need to ignore the insert operation. You could do something like this
if (action == 'insert') { ignore = true; }
if (action == 'update') {
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', 'testServer.001');
gr.query();
if (gr.next())
{
target.sys_id = gr.sys_id;
}
}