Getting count in REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:44 AM
Hi ,
How to get row count for table API in Rest.In simple i want to get no of records extracted using Table api.
Ex:
https://instance.service-now.com/api/now/table/incident?sysparm_query=sys_created_onBETWEENjavascript:gs.dateGenerate('2019-04-03','00:00:00')@javascript:gs.dateGenerate('2019-04-03','16:59:59')^incident_state=4&sysparm_display_value=true&sysparm_exclude_reference_link=true&sysparm_fields=number%2Ccaller_id%2Cincident_state%2Ccontact_type%2Csubcategory%2Cu_tertiary_category%2Cshort_description%2Cu_vendor_name%2Cu_alternate_contact_number%2Cu_alternate_phone%2Cu_alternate_email_address%2Ccategory%2Cimpact%2Curgency%2Cpriority%2Copened_by%2Copened_at%2Cu_case_type%2Cu_next_action_2%2Cu_next_action_1%2Cassigned_to%2Cu_callback_start_date%2Cclose_code%2Cu_closure_codes_2%2Cclose_notes%2Cdescription&sysparm_limit=100&sysparm_offset=0 --> for this i need to get the count of extracted records.
Thanks,
Arjun.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:57 AM
Hi Arjun,
Parse the json response; since multiple records are there the json would contain array of json objects.
you can get length from that
var parser = new JSONParser();
var parsedData = parse.parse(response);
var length = parsedData.result.length; // whenever system returns list of records result is the parent key so it will have array of objects within it
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 04:16 AM
Hi Ankur, I am using Table API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 02:57 AM
Hi Arjun,
You can use the URL extension for this, add sys parameter values. You can try using REST API Explorer for perfect results in the initial stage, sysparm_count=true will help you here. The final URL looks like this:
Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 04:14 AM
hello Akash,
i tried this ,but of no use
Thanks,
Arjun