Fix script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 02:52 AM
Hi all,
I want to copy records from a field in child table to a field in parent table I have tried fix script for this but its not copied can you please help me to do this. and this is the script I have tried
(function executeRule(current) {
var parentTable = 'cmdb_ci_service_auto';
var childTable = 'cmdb_ci_service_discovered';
var parentRecord = new GlideRecord(parentTable);
if (parentRecord.get(current.parent)) {
var childRecord = new GlideRecord(childTable);
if (childRecord.get(current.child)) {
parentRecord.u_ug_it_service_owner = childRecord.u_it_service_owner;
parentRecord.update();
}
}
})(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 06:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 08:56 PM
HI @Maddysunil
Try this logic .. i have tested in my PDI
var parentTable = 'incident';
var childTable = 'incident';
var childRecord = new GlideRecord(childTable);
if (childRecord.get('968dd5a893650210938374dcebba10ab')) {
gs.info('Child record found: ' + childRecord.getDisplayValue());
var parentRecord = new GlideRecord(parentTable);
if (parentRecord.get(childRecord.parent_incident)) {
gs.info('Parent record found: ' + parentRecord.getDisplayValue());
parentRecord.contact_type = childRecord.contact_type;
parentRecord.update();
gs.info('Field value copied successfully.');
} else {
gs.info('Parent record not found for sys_id');
}
} else {
gs.info('Child record not found for sys_id');
}
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 08:59 PM
My Results Parent Incident : INC0000044
Child Has Channel : Phone
Tested Code Logic
Parent Channel has Updated to Phone