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.

How to get distinct values from property in table using API?

Szymon Katar
Kilo Explorer

Hello everyone,

I used to visit this forum from time to time, but I never thought I will ask for help.
I have a very interesting case. I am using Import Set Api to transfer Objects to table - let's name it TableA.
I've got some properties in it for example PropertyA, PropertyB, PropertyC.
I can only import object to table, if it's properties are already in the table.

Since I am working on validation software in my application I am looking for ways for returning from table possible distinct values for property.

I am trying to use quering, but it's highly inaffective (takes long time):
URL/api/now/table/TABLE_NAME?sysparm_fields=PROPERTY_NAME&sysparm_limit=1500

I am not asking for a solution, but maybe You can guide where should I look?

To make thinks worse, I am using a stagigng tables, so most likely after some time data are moved to other table.

Best regards,

2 REPLIES 2

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Szymon,

Not sure but if performance is a problem to query the table, may be it would be faster to create a Scripted REST API that would check the table before updating and ignore if the query doesn't return any record.

https://docs.servicenow.com/bundle/sandiego-application-development/page/integrate/custom-web-servic...

Hello Hitoshi,
Thanks for a reply. So in this scripted rest api I can define a query that will return me a list of distinct value from each property? I've read the documentation about it, but still not sure how it works - never used it before. 
BR