
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 08:31 AM
I'm looking to synchronize a custom field [u_location_detail] on the Hardware asset table (alm_hardware) and Computer tables (cmdb_ci_computer). I see that I can use AssetAndCISynchronizer if I add both fields to the alm_asset and cmdb_ci tables. Unfortunately that adds u_location_detail to all extended tables below which is not wanted.
Any other thoughts on how to keep data synchronized between these two fields? Is there a best practice?
With parent tables such as task it is best practice not to add fields to task, is that not the case with cmdb/asset?
[Running on Jakarta]
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 10:34 AM
Thanks, that's what I had tried to do initially but left it once I discovered AssetAndCISynchronizer
After business rule on alm_hardware
(function executeRule(current, previous /*null when async*/) {
var field = current.u_locationdetail;
if (current.u_locationdetail != previous.u_locationdetail) {
var ccc = new GlideRecord("cmdb_ci_computer");
ccc.addQuery("table", "alm_hardware");
ccc.addQuery("sys_id", current.ci);
ccc.query();
if (ccc.next()) {
ccc.setValue("u_locationdetail", field);
ccc.update();
}
}
})(current, previous);
After business rule on cmdb_ci_computer
(function executeRule(current, previous /*null when async*/) {
if (current.u_locationdetail != previous.u_locationdetail) {
var ah = new GlideRecord("alm_hardware");
ah.addQuery("ci", current.sys_id);
ah.query();
if (ah.next()) {
ah.setValue("u_locationdetail", current.u_locationdetail);
ah.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 08:51 AM
Set up a business rule that tracks the change on either field and replicate the data to the corresponding field in the target table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 10:34 AM
Thanks, that's what I had tried to do initially but left it once I discovered AssetAndCISynchronizer
After business rule on alm_hardware
(function executeRule(current, previous /*null when async*/) {
var field = current.u_locationdetail;
if (current.u_locationdetail != previous.u_locationdetail) {
var ccc = new GlideRecord("cmdb_ci_computer");
ccc.addQuery("table", "alm_hardware");
ccc.addQuery("sys_id", current.ci);
ccc.query();
if (ccc.next()) {
ccc.setValue("u_locationdetail", field);
ccc.update();
}
}
})(current, previous);
After business rule on cmdb_ci_computer
(function executeRule(current, previous /*null when async*/) {
if (current.u_locationdetail != previous.u_locationdetail) {
var ah = new GlideRecord("alm_hardware");
ah.addQuery("ci", current.sys_id);
ah.query();
if (ah.next()) {
ah.setValue("u_locationdetail", current.u_locationdetail);
ah.update();
}
}
})(current, previous);