incident updated in 'Incident' table. - Update the corresponding incident in 'Incident_temp' table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:17 PM
Hi All,
I have below requirement,
- Create a business rule called ' Update Temp Incident Rule' - This should execute only whenever any
incident updated in 'Incident' table.
- Update the corresponding incident in 'Incident_temp' table and update Short description.
I have create one BR but it is not working properly. previous record has been updated by using my BR.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.info("test4");
var gr = new GlideRecord("u_incident_temp");
gr.query("u_incident_number ", current.number);
gr.query();
gs.info("line8"+current.number);
if(gr.next())
{
gs.info("line11"+current.number);
gr.setValue('u_short_description', current.getValue('description'))
gr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:27 PM
Hi Keval,
Is the u_incident_number field a reference field or a string field which inputs the incident number?
Below line of code is missing addQuery()
gr.addQuery("u_incident_number ", current.number);
Below line can be alternatively written as
old: gr.setValue('u_short_description', current.getValue('description'))
new: gr.u_short_description =current.description
If my answer helped you in any way please mark it as correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 11:18 PM
Hi @keval3 ,
Try this below code in your BR,
var gr = new GlideRecord("u_incident_temp");
gr.addQuery("u_incident_number ", current.number);
gr.query();
if(gr.next())
{
gr.u_short_description = current.description;
gr.update();
}
If it is helpful please make it correct/helpful.
Thanks and Regards,
Allu Gopal.