Problem

P1234
Tera Contributor

Hi,

 

My task is when the user open incident need to update the Description and short description and then automatically update same description & short description in the problem record.

 

I'm executing code but not working.

 

when to run :  Description : changes

                        Problem : is same : as --> problem

 

if (current.description != previous.description) {

        var problem = new GlideRecord('problem');
        problem.addQuery('sys_id', current.problem_id);
        problem.query();
        if (problem.next()) {
            problem.description = current.description;
problem.short_description = current.short_description;
            problem.update();
        }
    }
1 ACCEPTED SOLUTION

Hi @P1234 

 

Hope you are good.

 

Below is the solution for your query, basically you should use After Update Business rule.

PFA the screenshots, this particular use case is perfectly working on my PDI, hope this helps! If this helps you to resolve your query, please mark it correct and accept the solution, Thanks 🙂

 

Below is the Code:

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

    if (current.short_description.changes() || current.description.changes()) {
        if (current.problem_id) {
            var prob = new GlideRecord('problem');
            if (prob.get(current.problem_id)) {
                prob.short_description = current.short_description;
                prob.description = current.description;
                prob.update();
                gs.info("Problem updated from Incident: " + current.number);
            }
        }
    }

})(current, previous);
If you found my response helpful, please give it a thumbs-up and designate it as solution accepted to support fellow developers and admins.


Regards,
Rathan K

View solution in original post

7 REPLIES 7

P1234
Tera Contributor

Hi Rathan,

 

Not working can you please share the testing screenshot.

Hi @P1234 

 

Please find the screenshots

RathanK_0-1750763925038.pngRathanK_1-1750763957932.png

Above 2 screenshots are the Incident record which has the problem has linked
Now I am changing the Description and the Short Description on the Incident Form and once I save it it automatically should change the Problem Statement and Description on the Problem Record.

RathanK_2-1750764118081.png

You can check the screenshot below the values are automatically changed on the Problem record as well. Hope this helps for you!

RathanK_3-1750764183324.png

 

Thanks,
Please feel free to reach me on LinkedIn if you still facing any issues within this use case ^_^
https://www.linkedin.com/in/snrnk140999/

If you found my response helpful, please give it a thumbs-up and designate it as solution accepted to support fellow developers and admins.


Regards,
Rathan K

Shruti
Mega Sage
Mega Sage

Shruti_0-1750760907479.png

 

Shruti_1-1750760930349.png