Add Problem Task resolution information to problem but don´t replace problem resolution notes

jthomsen
Tera Contributor

When the task is completed, the following information should be transferred from the task to the problem:

- "Workaround" (task) is written to the "Workaround" (problem) field if content is available

- "Notes on cause" (task) is written to the "Notes on cause" field if content is available

- "Notes on proposed solution" (problem) is written to the "Notes on solution" field, if content is available.

The contents of the problem fields should not be overwritten, but the new information should be preceded by the date/time in the fields and separated 

"Date/Time (new)

Workaround information (new)

----------------------------------

Date/Time (old)

Workaround information (old)"

3 REPLIES 3

AshishKM
Kilo Patron
Kilo Patron

Hi @jthomsen ,

Write a BR [after: update] on problem task table, and update the task value to problem record via parent column record, while updating PRB record use the concatenation for fields and user ("\n") for line break.  Share the code if you stuck in steps.

 

-Thanks,

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM ,

 

(function executeRule(current, previous /* previous is the previous record state */) {
        var problem = new GlideRecord('problem');
        problem.get(current.getValue('problem'));

        var existingSolutionHints = problem.hints_to_solution || '';

        var workaroundInfo = current.getValue('workaround') || '';
        var causeNotes = current.getValue('cause_notes') || '';
        var fixNotes = current.getValue('fix_notes') || '';

        var newEntry = gs.nowDateTime() + "\n\nWorkaround:\n" + workaroundInfo + "\n\nCause Notes:\n" + causeNotes + "\n\nFix Notes:\n" + fixNotes + "\n\n----------------\n\n" + existingSolutionHints;

        problem.hints_to_solution = newEntry;
        problem.update();
 
This is my current code but it´s not working

Hi @jthomsen , 

Replace the code with below updated code, this code will update the PRB with existing update.

 

(function executeRule(current, previous /*null when async*/ ) {
    // Add your code here
    var prob = new GlideRecord('problem');
    prob.addQuery('sys_id', current.problem);
    prob.query();
    var gdt = new GlideDate().getDate();
    if (prob.next()) {

        prob.workaround = current.workaround + "(" + gdt + ")" + "<hr>" + prob.workaround;
        prob.cause_notes = current.cause_notes + "(" + gdt + ")" + "<hr>" + prob.cause_notes;
        prob.fix_notes = current.fix_notes + "(" + gdt + ")" + "<hr>" + prob.fix_notes;
        prob.update();

    }

})(current, previous);

Test this first and you can add all 3 fields together for "hints_to_solution".

 

-Thanks,

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution