- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:08 AM
Hi,
I am working on a scenario where the Description field from a Problem record will be copied to associated incident records once the problem record is saved. I have done everything but the Description in Incident records is not getting updated with the Description of the problem record once is saved the problem record. Kindly help.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord("incident");
gr.addQuery('problem_id', '3D62304320731823002728660c4cf6a7e8');
gr.query();
while(gr.next()){
gr.description = current.description;
gr.update();
}
})(current, previous);
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:26 AM
Hello @Community Alums ,
You need to create a BR on after insert/Update on problem table and follow the below script that will help you. I tried in my PDI it is working as expected.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc = new GlideRecord("incident");
inc.addQuery("problem_id",current.sys_id);
inc.query();
if(inc.next()){
inc.description=current.description;
}
inc.update();
})(current, previous);
Please mark my answer as accepted solution and give thumbs up, if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:26 AM
Hello @Community Alums ,
You need to create a BR on after insert/Update on problem table and follow the below script that will help you. I tried in my PDI it is working as expected.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc = new GlideRecord("incident");
inc.addQuery("problem_id",current.sys_id);
inc.query();
if(inc.next()){
inc.description=current.description;
}
inc.update();
})(current, previous);
Please mark my answer as accepted solution and give thumbs up, if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:33 AM
Hi @Abhishek_Thakur ,
Thank you, it worked, but I have a question please. How is that if condition worked even though there are many incidents.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:41 AM
Hello @Community Alums ,
You can use the "while" istead of "If" for the many incidents.
Please mark my answer as accepted solution and give thumbs up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 02:42 AM
Hello @Community Alums ,
If my given code worked for you, could you please accept the solution and give thumbs up. So, that it can help other if they will stuck in the same scenario.