The CreatorCon Call for Content is officially open! Get started here.

When Incident closed the associated problem should be closed automatically...?

Jaya Chandra Re
Tera Contributor

I am creating new problem record when incident created with BR. its working as expected. but the issue is when i resolve the incident the associated problem should be closed automatically. but its my code is not working as expected. below i am sharing my script and conditions for the reference. Please any help would be appreciated. T

 

After BR - Update , Table- Incident.

JayaChandraRe_0-1714305094138.png

JayaChandraRe_1-1714305118101.png

i have added infoMessages for testing and those are triggered correctly.

 

JayaChandraRe_2-1714305156194.png

 Thanks in advance

 

1 ACCEPTED SOLUTION

Ashutosh C J
Tera Guru

Hi @Jaya Chandra Re 
Use the below script but lets try to understand few things
1) We should use gr.addQuery("sys_id", current.problem_id) because you can see problem_id is present on the incident form and when you are querying problem table, you should compare the sys_id of problem with the sys_id present in problem_id
2)You can open the dictionary of state field in problem table. Go to the choices and bring the table field. Among all the choices that are closed, only 107 is a match for problem table. Please refer the attached screenshot
3) Once you have confirmed everything as mentioned above, use the below script. It will be after update BR and condition also remains same

AshutoshCJ_0-1714313183756.png

 

 

 

    var probRcd = new GlideRecord('problem');
    probRcd.addActiveQuery();
    probRcd.addQuery("sys_id", current.problem_id);
    probRcd.query();
    if (probRcd.next()) {
        probRcd.state = '107';
        probRcd.update();
    }

 

 

View solution in original post

10 REPLIES 10

Seraj
Tera Guru

Hi @Jaya Chandra Re ,

In the problem record there some mandatory field that we have to fill to move state from new to resolved.

So for that i have created on script please try this once

 var gr = new GlideRecord('problem');
    gr.addQuery('sys_id', current.problem_id);
    gr.query();
    if (gr.next()) {
        gr.setValue('state', '106'); //check the backend name of resolved state
        gr.setValue('fix_notes', 'Provide fix notes here');
        gr.setValue('cause_notes', 'Provide cause notes here');
        gr.setValue('resolution_code', 'fix_applied')
        gr.update();
    }