- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 09:17 AM
Hello,
the client asked for a capability to Import New Vulnerable Items by a spreadsheet. A transform map has been created for that and now the next requirement is that if the Configuration Item is not found then a new one is created under the "Unclassed Hardware" class.
Since there are several ways to trigger a script in a transform map, I don't know which one to use:
- Transform Script and what type
- Source Script for the CI field
- or Script on the Transform map record (the one that appears when you check "Run script")
Does anybody know which one to use and how to begin, please?
Thank you, guys.
Patrik
Solved! Go to Solution.
- Labels:
-
Vulnerability Response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 05:26 AM
Hi,
Here is an outline of how to do this:
1. Using a Transform Map, map as many fields as possible.
2. Create an On-before Transform Script and place all of your heaving liftings into a Script Include
3. You need to do a look-up and get a match for the Vulnerability and the Configuration Item
(Advanced / Optional) Here is how you can leverage CI Lookup Rules while you are trying to match on a CI:
https://gist.github.com/cmcdevitt/72033b66335c2ab00af30214f76e4c2e
I would take a half hour and read through the docs on Import Sets:
https://docs.servicenow.com/bundle/tokyo-platform-administration/page/administer/import-sets/reference/import-sets-landing-page.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 10:33 AM
You can use the Source script for this.
In your source script you can look for the CI record by passing the source value if the record exists you can return the corresponding sysid ,
else you can have the logic to insert the record in source script and return the sysid of new record after the insert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 10:36 AM
Hi
I always found the following page helpful when deciding which kind of script to use: https://docs.servicenow.com/en-US/bundle/sandiego-platform-administration/page/script/server-scripti...
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 05:26 AM
Hi,
Here is an outline of how to do this:
1. Using a Transform Map, map as many fields as possible.
2. Create an On-before Transform Script and place all of your heaving liftings into a Script Include
3. You need to do a look-up and get a match for the Vulnerability and the Configuration Item
(Advanced / Optional) Here is how you can leverage CI Lookup Rules while you are trying to match on a CI:
https://gist.github.com/cmcdevitt/72033b66335c2ab00af30214f76e4c2e
I would take a half hour and read through the docs on Import Sets:
https://docs.servicenow.com/bundle/tokyo-platform-administration/page/administer/import-sets/reference/import-sets-landing-page.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 05:48 AM
I think in your case, its better to have onBefore script as script will create entry in ci table and your field map will map it properly as record will be there in table while mapping.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP