change request logs show Invalid query detected, please check logs for details

Kiran_25
Tera Expert

When you use a standard change template to create a new change req and save the record, a business rule is displaying an error message. The business rule should only display the msg if a field which was populated via template has had a value has changed which is not the case,  however Logs are showing 'Invalid query detected, please check logs for details [Unknown field incident in table cmdb_ci_outage]' 

I dont see how the 2 are connected but this is what im seeing.

2 REPLIES 2

Yousaf
Giga Sage

Hi Kiran,
This is what I could find there is a support article for this issue. You need to check for the business rule on Affected table. Please find the link to this article below. I am pasting the article if link doesnt work

Issue
Troubleshoot the error "Invalid query detected, please check logs for details [Unknown field undefined in table sc_request]" that appears in the log table or system logs. The table name in the error message varies depending on the affected table.
Invalid query detected, please check logs for details [Unknown field undefined in table sc_request]
Release
All supported releases
Cause
This error is produced by a business rule on the affected table (the table name appears in the error message, for example, sc_request).
The business rule calls the GlideRecord function next() on a GlideRecord object when that object has no more records to return.
Example: 
 var gr = new GlideRecord('sc_request');
 gr.addQuery('sys_id', current.request);
 gr.query();
 gr.next();  //<----- Problem line

This code returns only a single row, but gr.next() is called without a conditional check. This triggers the invalid query error.
Resolution
Avoid using gr.next() on a GlideRecord object outside of a conditional statement. Without a conditional check such as a while loop or an if statement, calling gr.next() is equivalent to an out-of-bounds error in an array.
If only one record is expected and the unique sys_id is known, use gr.get() instead:

***Mark Correct or Helpful if it helps.***

PoonkodiS
Giga Sage

Hi @Kiran_25 

Relationship between the two tables are:

PoonkodiS_0-1779397511567.png

Unknown field incident in table cmdb_ci_outage,happens because the script incorrectly assumes the Outage table contains a direct incident reference field.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0863715

 

Hope it helps