Problem have incidents

Abhimitrake
Tera Contributor

Dear Team,

 

(function executeRule(current, previous /*null when async*/ ) {
    // # Assignment 3: Problem have incidents
    // > if problem is updated with worknotes - update the same to all the incident.
    // > if problem is closed - resolved or close all the child incidents.
    var gr = new GlideRecord('incident');
        gs.log('1');
    if (current.work_notes.changes()) {
        gs.log('2');
        gr.addQuery('problem_id', current.sys_id);
        gr.query();
        while (gr.next()) {
                gs.log('3');
            gr.work_notes = current.work_notes;
            gr.setWorkflow(false);
            gr.update();
        }
    }
    if (current.state == '107' || current.state == '106') {
            gs.log('4');
            gr.addQuery('problem_id', current.sys_id);
            gr.query();
            while (gr.next()) {
                    gs.log('5');
                gr.state = '7';
                gr.setWorkflow(false);
                gr.update();
            }

        }
    })(current, previous);
 
 
the Business Rule script is not executed,
 
can anyone help me with this
 
1 ACCEPTED SOLUTION

PoonkodiS
Mega Sage

Hi @Abhimitrake 

I tried in my pdi

PoonkodiS_0-1769465635959.pngPoonkodiS_1-1769465717144.png

 And , I created the problem record with two child incidents

PoonkodiS_2-1769465816955.pngPoonkodiS_3-1769466021484.pngPoonkodiS_4-1769466070861.png

Regards,

Poonkodi

View solution in original post

2 REPLIES 2

brianlan25
Kilo Patron

What type of business rule is it? What are the conditions on the business rule?

Additional Note: The part about resolving an incident when the problem is resolved exists out of the box. The incident just need to be in the state of on hold and the on hold reason need to be awaiting problem.

PoonkodiS
Mega Sage

Hi @Abhimitrake 

I tried in my pdi

PoonkodiS_0-1769465635959.pngPoonkodiS_1-1769465717144.png

 And , I created the problem record with two child incidents

PoonkodiS_2-1769465816955.pngPoonkodiS_3-1769466021484.pngPoonkodiS_4-1769466070861.png

Regards,

Poonkodi