How to avoid quering table twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:17 PM
Hi ,
As per our requirement we have an field in incident table parent incident if parent incident field is filled then we have custom filed set as true for the parent incident .
whenever parent incident value changes in the child incident the custom field set as false for the parent incident . The new parent incident custom filed set as true.
Below script is working as expected but need to avoid two time gliderecording of table how to achieve the same logic
var gr = new GlideRecord('incident');
if (current.parent_incident) {
gr.get('sys_id', current.parent_incident);
gr.parent_incident_checkbox = true;
gr.update();
}
if (current.parent_incident.changes()){
var gr1 = new GlideRecord('incident');
gr1.get('sys_id', previous.parent_incident);
gr1.parent_incident_checkbox = false;
gr1.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:24 PM
Hello @Munny1
You can use this -
var gr = new GlideRecord('incident');
if (current.parent_incident.changes()){
var gr1 = new GlideRecord('incident');
gr1.get('sys_id', previous.parent_incident);
gr1.parent_incident_checkbox = false;
gr1.update();
}
else if (current.parent_incident) {
gr.get('sys_id', current.parent_incident);
gr.parent_incident_checkbox = true;
gr.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 10:25 PM - edited 11-13-2023 10:27 PM
u also glide recorded incident table two times i need to avoid that. Even previously my script also working as expected