Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Case API returning "record not found" when querying with number

ManasiP
ServiceNow Employee
ServiceNow Employee

When we used the GET with the case number to query case by id, the result is "record not found". If i changed to the case sys_id, everything works fine.

I checked and found that it's failing when we do if (gr.get('number')), which returns false, so the rest of the logic is not executed.

Has anyone faced this issue and been able to resolve it?

1 ACCEPTED SOLUTION

@ManasiP 

as you can see it's using GlideRecordSecure so it will evaluate ACL for your API user

is that user able to see that in UI using normal table list?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Hi @Ankur Bawiskar ,

It’s not working with the admin persona either, and the customer has not done any customization. The root cause appears to be the getCaseById OOB method — the line caseGr.get(id) is returning false, so the logic inside the block is not executed.

getCaseById : function(id, displayValue, selectedFields) {
this.logger.info("inside CaseDao:getCaseById id = " + id);
var caseObj = null;
if (id) {
var caseGr = new GlideRecordSecure("sn_customerservice_case");
if (caseGr.get(id)) {
caseObj = this.prepareCaseObject(caseGr, displayValue, null, selectedFields);
this.logger.debug("inside CaseDao:getCaseById caseObj = " + JSON.stringify(caseObj));
}
}
return caseObj;
}

Also, the customer has disabled the Query Rules and for query br's, I inactivated all, still the issue was observed. These have not done any customisation as well on these api's.
Do you think any another reason which can cause this.

@ManasiP 

as you can see it's using GlideRecordSecure so it will evaluate ACL for your API user

is that user able to see that in UI using normal table list?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Actually we are doing it with admin persona and for admin as well its failing, removing the gliderecordsecure t gliderecord is not working as well

Actually its not working for admin persona as well.
Even if I remove gliderecordsecure to gliderecord its failing