How to update/add to a table's related list using an import set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 01:43 PM
I need to upload an import set (from a csv file) describing attributes of some servers. I've extended the 'Linux Server' table and added a few fields.
However, I can't find any info on how I can create a transform map to add to related lists. For example, I'd like to add a disk drives, networks, software, etc. as listed in the tabs in the image below using the data already in my csv file.
These items certainly don't show up in the mapping assist slush bucket, so I suspect some scripting will be required (not a problem).
Are there any articles or examples of doing anything like this? I've searched quite a bit and can't find anything.
(Well, I did find one discussion on here that tantalizingly seemed to answer this question perfectly, but it pointed to some example code on another web site that no longer exists)
As always, any help is most appreciated.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 01:51 PM
Hi
All the related lists are the individual tables in Service Now and there is no way of updating the fields information directly from the transform map for the target table.
If you want to use only one transform map, then the transform scripts should be defined to glide into all the related list tables and update the information.We can do it by using some common code ( function call) for update of the information.
The other solution to keep it simple, define multiple transform maps, one for each target table(related list).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 02:32 PM
You can add Transform Scripts to your Table Transform Map. Add an 'onAfter' script to your map. This functions just like an onAfter business rule. But you won't have a 'current' context. Instead you have a 'target' context. Each time you insert a row into the target via the transform, the onAfter script will run.
The script can insert records into your related table. Simply set the reference field on the related record to the sys_id of the record that's been inserted by the transform map (target.sys_id).
Here's a very rough example that creates a new record in the Software instance table (cmdb_software_instance):
var sftInst = new GlideRecord('cmdb_software_instance');
sftInst.software = source.softwareName;
sfInst.installed_on = target.sys_id;
sfInst.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2015 02:41 PM
Thank you Sandra! I'm going to give this a shot. It looks exactly like what I was after! I really appreciate your giving an example. That's incredibly helpful! If I'm successful, I'll mark your answer as THE answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 11:23 AM
Hi Sandra,
I am having similar requirement where I need to load the server data and the related application data which are running on each server.
I have created M2M relationship and added the application under related list of server form. I am able to select the available applications from the slush bucket and create the new applications as well. Now I want to load all the applications
Could you Please help me in creating the onAfter transform script to load related applications.
Regards,
RRR