How to copy Worknotes and comments from work order to its parent Request and associated Case

Research
Tera Guru

Hi 
Can any one guide me 

how to copy worknotes and additional comments from workorder(FSM) 
To its parent Service Request ticket and  and then to the Case ticket

 

Please guide and help me with script.

 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @Research ,
I trust you are doing great.

 

Here's a basic outline for such a script in a business rule:

 

(function executeRule(current, previous /*null when async*/) {

    // Assuming 'parent' is the reference field to the Service Request
    var serviceRequestGR = new GlideRecord('service_request_table'); // Replace with your Service Request table name
    if (serviceRequestGR.get(current.parent)) {
        // Copy worknotes and additional comments
        serviceRequestGR.work_notes = current.work_notes; // Adjust field names as necessary
        serviceRequestGR.comments = current.comments; // Adjust field names as necessary
        serviceRequestGR.update();

        // If the Service Request is linked to a Case, repeat the process
        var caseGR = new GlideRecord('case_table'); // Replace with your Case table name
        if (caseGR.get(serviceRequestGR.parent)) { // Assuming the Case is linked in a similar way
            caseGR.work_notes = current.work_notes;
            caseGR.comments = current.comments;
            caseGR.update();
        }
    }

})(current, previous);
 

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

HI @Research ,
I trust you are doing great.

 

Here's a basic outline for such a script in a business rule:

 

(function executeRule(current, previous /*null when async*/) {

    // Assuming 'parent' is the reference field to the Service Request
    var serviceRequestGR = new GlideRecord('service_request_table'); // Replace with your Service Request table name
    if (serviceRequestGR.get(current.parent)) {
        // Copy worknotes and additional comments
        serviceRequestGR.work_notes = current.work_notes; // Adjust field names as necessary
        serviceRequestGR.comments = current.comments; // Adjust field names as necessary
        serviceRequestGR.update();

        // If the Service Request is linked to a Case, repeat the process
        var caseGR = new GlideRecord('case_table'); // Replace with your Case table name
        if (caseGR.get(serviceRequestGR.parent)) { // Assuming the Case is linked in a similar way
            caseGR.work_notes = current.work_notes;
            caseGR.comments = current.comments;
            caseGR.update();
        }
    }

})(current, previous);
 

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi