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.

Filters in REST calls?

benbaldwin
Tera Contributor

How do you set up a filter in the Query Parameter section of a REST Data Source Request? I've got a connection to a SQL Server database that works fine to pull all of the records in the table, but I need to limit that. I haven't been able to figure out how to construct the filter for the REST call. Any help would be greatly appreciated.

find_real_file.png

6 REPLIES 6

Pavankumar_1
Mega Patron

Hi,

you can use the SQL statement and add the filter to get the unique data and refer below screen shot.

find_real_file.png

 

Example:

SELECT
  it.ITEMID AS ItemNumber,
  ISNULL(cidc.CUSTOMERDESCRIPTIONID, '') AS DescriptionID,
  ISNULL(cidc.[DESCRIPTION], '') AS ShortDescription
FROM INVENTTABLE it
WHERE 
it.DATAAREAID  IN ('DUS')
AND it.MODIFIEDDATETIME >= convert(VARCHAR, getdate() - 2, 101)

as highlighted above it will get the last 2 days modified records.

you can condition something like this based on the source system data.

 

Hope it helps!!

Please Mark ✅ Correct/helpful, if applicable, Thanks!! 

 

Regards

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Pavankumar_1
Mega Patron

Hi,

 

Please close the thread and Mark ✅ Correct/helpful.

or  Let me know if you are looking for anything else.

 

Thanks,

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Pavan, I'm working with a flow action Data Source Request. Unfortunately entering the sql query there doesn't work.

Hi,

My apologies, I understood you are requirement differently.

May below articles help you out.

 

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

https://community.servicenow.com/community?id=community_question&sys_id=f090120edb2414105129a851ca9619f5

https://developer.servicenow.com/print_page.do?release=rome&category=learning-module&identifier=app_store_learnv2_rest_rome_cors_rules,servicenow_application_developer&module=learning%20plan

 

Thanks,

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar