Searching the user table for user using custom field

leenathan24
Kilo Contributor

I am creating a form that takes customer information and creates a record from that information. I was originally using a field that was using the AJAXTableCompleter attribute, but for reasons I won't go into that option doesn't work for me. So I need to create a field that runs custom script through a UI policy to search the User table. My initial idea was that I would create a GlideRecord of the sys_user table:

var gr = new GlideRecord("sys_user");

And then use that object to look through the different columns in the user table to see if there is a match with what the user typed into the field. But I'm not sure how to dot-walk from the `gr` object to the appropriate sys_user columns and then iterate through their elements to search for a match. Can I get some guidance on how I should be doing this?

For some further context, I already setup the minimal script I have to run only when the text entered into the field matches a specific pattern, so that part is not a problem. It's just the searching that is the trouble.

Thank you!

6 REPLIES 6

I was...



Can you explain why I need to do it in a script include with GlideAjax and why my method was incorrect?


venkatiyer1
Giga Guru

Accessing server side code from client script directly is not allowed. Now Glide Record is a server side code to access database records. So to do that we need a server side javascript and that would be a script include. The way to access a Script include from a client side is to make an Ajax call using Glide Ajax.



GlideAjax - ServiceNow Wiki