checking if a record exists using get()

ServiceNow Use6
Tera Guru

Hello,

I wrote a script where I can check if a record exists with the following condition and it is not able to find.

var methods = new GlideRecord("incident");
var returnValue = methods.get("caller_id", "Bud Richman");
gs.addInfoMessage("the record that is to be returned is available " + returnValue);

It is returning false even though there is  record with the scenario

Regards

Suman P.

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

methods.get("caller_id", "Bud Richman");

caller_id is a reference, so sys_id. You are searching on a string though. That won't work.

So either search on the sys_id, or use caller_id.name

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

ServiceNow Use6
Tera Guru

Got it Ankur. It worked. Thanks Mark.

Regards

Suman P.