Invalid query detected, please check logs for details [Unknown field null in table incident]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2023 11:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 11:16 AM
Did you check the logs for details? If I had to guess, I would say it's this line that it doesn't like:
var incidentNum = incidentGR.number;
You haven't executed a GlideRecord to return the entire record object that was created, so you can't reference a field in that object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 12:48 PM
I don't think the problem is because of this code, but some other BR (or code) that is triggered by inserting an incident record.
To test this you should add instruction
incidentGR.setWorkflow(false);
before
incidentGR.initialize();
b.t.w, while at it, you should use
incidentGR.newRecord()
instead of initialize.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 01:14 PM
Additional info: as far as I know, errors with description "Invalid query detected" are produced by select filters, not other DB operations.
That is why, the code shown could not produce such errors - it only inserts, it does not filter and select.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 12:48 PM
Hi @Aakriti_Poudel ,
Plz try with below code
(function executeRule(current, previous /*null when async*/) {
try {
// Set up incident record
var incidentGR = new GlideRecord('incident');
incidentGR.initialize();
incidentGR.setValue('short_description', 'Group Deleted: ' + current.name);
incidentGR.setValue('assignment_group', '12a586cd0bb23200ecfd818393673a30'); // incident management group
incidentGR.setValue('caller_id', '6816f79cc0a8016401c5a33be04be441'); // system administrator
var sysID = incidentGR.insert();// fetch sysid of created incident
// Fetch incident number
var gr = new GlideRecord('incident');
if(gr.get(sysID)){
// Send email notification
var groupName = current.name;
var incidentNum = gr.number;
gs.eventQueue('delete.notification.registry', incidentGR, current.name, incidentNum);
}
} catch (ex) {
gs.error('Error in business rule: ' + ex);
}
})(current, previous);
Thanks,
Danish