Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function executeRule(current, previous /*null when async*/) {

// Call the Script Include
var populator = new DynamicFieldPopulator();
populator.populateFields(current, current.getTableName());

})(current, previous);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Project Description

Dynamic Field Population from CMDB is a reusable ServiceNow solution that automatically fills key fields on incidents, tasks, or change requests based on the selected Configuration Item (CI). By fetching data such as Owner, Assignment Group, Location, Department, and Business Service directly from the CMDB, this project reduces manual effort, ensures data consistency, and improves ITSM efficiency.

It leverages a Business Rule that triggers on record insert or update, combined with a Script Include that handles dynamic mapping of CI fields to target fields. The solution can be extended for multiple tables, integrated with the Service Portal via GlideAjax, and configured using a JSON or mapping table for maximum flexibility.

Key Benefits:

Saves time for agents by auto-filling fields.

Reduces errors and ensures standardized data.

Reusable across multiple tables (Incident, Change, Problem).

Easily configurable for different CI-to-field mappings.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var DynamicFieldPopulator = Class.create();
DynamicFieldPopulator.prototype = Object.extendsObject(AbstractAjaxProcessor, {

populateFields: function(currentRecord, tableName) {

// Ensure CI is selected
if (!currentRecord.cmdb_ci) return;

// Fetch CI record
var ciGR = new GlideRecord('cmdb_ci');
if (!ciGR.get(currentRecord.cmdb_ci)) return;

// Mapping: CI field -> Target record field
var mapping = {
"owned_by": "assigned_to",
"assignment_group": "assignment_group",
"location": "location",
"department": "u_department", // custom field example
"business_service": "cmdb_ci_service"
};

// Loop through mapping and populate fields if empty
for (var ciField in mapping) {
var targetField = mapping[ciField];
if (!currentRecord[targetField] || currentRecord[targetField] == '') {
currentRecord[targetField] = ciGR.getValue(ciField);
}
}

return currentRecord; // optional, for reusability
}

});
Loading