The changes made in X form should reflect on Y form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2025 06:00 PM
I have two forms X and Y
Both forms have similar fileds called compact which needs to be filled
If the filed compact is filled in X form it should automatically get updated in Y when they are linked with the common filed value Sec
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2025 11:32 AM
You can create a Business rule on table x that runs on change of compact field. Update the table Y with the new value
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2025 01:57 PM
Hi @palanikumar I have written the below business rule but it wasn't working
(function executeRule(current, previous /*null when async*/) {
// Only run if any of the three fields changed
if (current.compact.changes() || current.description.changes() || current.status.changes()) {
var yRec = new GlideRecord('table_Y'); // replace with actual table name
yRec.addQuery('sec', current.sec); // match common field
yRec.query();
while (yRec.next()) {
var updated = false; // track if anything changed
if (current.compact.changes()) {
yRec.compact = current.compact;
updated = true;
}
if (current.description.changes()) {
yRec.description = current.description;
updated = true;
}
if (current.status.changes()) {
yRec.status = current.status;
updated = true;
}
if (updated) {
yRec.update();
}
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2025 11:53 PM
Hi @ark257 ,
Use a Business Rule on one table (say X) that finds the matching record in Y by Sec and copies the compact value across whenever it changes
Option 1: One‑way sync (X → Y)
Assumptions:
Table X: u_table_x, field: u_compact, key: u_sec
Table Y: u_table_y, field: u_compact, key: u_sec
Business Rule on X
Table: u_table_x
When: after insert and after update
Condition: current.u_compact.changes()
(function executeRule(current, previous /*null when async*/) {
if (!current.u_sec)
return;
var y = new GlideRecord('u_table_y');
y.addQuery('u_sec', current.u_sec);
y.query();
if (y.next()) {
y.u_compact = current.u_compact;
y.update();
}
})(current, previous);
​This keeps Y’s compact in sync whenever X’s compact is filled/changed
You may find below thread helpful:
- https://www.servicenow.com/community/developer-forum/sync-two-fields-in-different-tables/m-p/2159479
If it is helpful, please hit the thumbs button please mark the answer as correct based on the impact!!
Kind Regards,
Shaik Mohammed Mustaq
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I got the below error after writing the provided script
