
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 01:34 AM
Does anyone have a similar script for this or can advise how to achieve please.
We have a transform map on cmdb_model to create product models. One of the fields is the reference field to Manufacturer, and the Choice Action is set to create, so if the Manufacturer on the source information import is not referenced in core_company table, the transform will create a new entry.
The problem is that on core_company table there are three checkboxes for Customer, Manufacturer and Vendor, and so when a new company is created, we need to be able to set the Manufacturer checkbox to true (otherwise necessary business rules we have are automatically creating the new manufacturer in the class of account).
Question is how to set this on the new record created by the transform, when the transform is on cmdb_model.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 01:40 AM
Hi,
you can use onAfter transform script for this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var rec = new GlideRecord('core_company');
rec.get(target.company); // give here the field which refers to company table
rec.manufacturer = true;
rec.update();
})(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
‎09-06-2022 01:40 AM
Hi,
you can use onAfter transform script for this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var rec = new GlideRecord('core_company');
rec.get(target.company); // give here the field which refers to company table
rec.manufacturer = true;
rec.update();
})(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
‎09-06-2022 03:25 AM
Legend as ever, thanks Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 03:41 AM
Glad to help.
Please mark response helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader