- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2025 12:09 PM
Hi guys!
I'm sitting with a custom table 'x_vgll_decom_decommission', which also has a child task table 'x_vgll_decom_decommission_task'.
On these child tasks there are several dotwalked fields from the parent. So the business requirement is that IF you make any update on the child table (the task), whether it is a dot-walked field from parent or a task field, "Status" ('state') should go from 1 (new) to 2 (in progress).
Is this possible?
I tried with this Before Update Business rule, With condition "State" Is "New" (1), which is not working:
(function executeRule(current, previous /*null when async*/) {
// Kontrollera att state är "Ny"
if (current.state != 1) return;
// Om decommission-referensen har ändrats, ladda båda parent-records
var decommissionChanged = current.decommission != previous.decommission;
var currentParent = current.decommission.getRefRecord();
var previousParent = new GlideRecord('x_vgll_decom_decommission');
if (!previousParent.get(previous.decommission.toString())) {
// Om parent inte kunde hämtas, hoppa över
return;
}
// Lista på parentfält att jämföra
var fieldsToCompare = [
'decommission_server_text',
'decommission_server',
'decommission_database_text',
'decommission_database',
'decommission_website_text',
'decommission_website',
'decommission_other_text',
'decommission_other',
'decommission_access_control_text',
'decommission_access_control',
'decommission_storage_text',
'decommission_storage',
'decommission_integrations_text',
'decommission_integrations',
'decommission_monitoring_text',
'decommission_monitoring',
'decommission_client_parts_text',
'decommission_client_parts',
'service_to_decommission'
];
var hasChanged = false;
for (var i = 0; i < fieldsToCompare.length; i++) {
var field = fieldsToCompare[i];
var currentVal = currentParent.getValue(field);
var previousVal = previousParent.getValue(field);
if (currentVal != previousVal) {
hasChanged = true;
break;
}
}
// Om något fält har ändrats, sätt state till Pågående (2)
if (hasChanged) {
current.state = 2;
}
})(current, previous);
With my faulty business rule, the state goes from 1 to 2 directly, upon insert (when new task record is created).
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 05:50 AM
Ideally you should not allow updating dot walked fields as data for it resides at parent level.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2025 04:51 AM
@Ankur Bawiskar True, so I made mirror fields on child instead and these I try to sync to the parent.