- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 01:49 AM - edited 06-10-2024 01:50 AM
Hi community,
Can someone please help how to get the total row count from the below rest message script? I don't want to use 'maxRecordsToReturn' attribute. I want to get all records count from the response.
I tried removing maxRecordsToReturn but it's showing me some error.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 02:58 AM
@Ankita Kolhe This is 99 as your API returns maximum 100 records
"maxRecordsToReturn": 100
If you wish to get the exact number of records returned by the search term then you need to request your API team to check if any response parameter contains the count of total number of records.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 01:54 AM
@Ankita Kolhe If you wish to know the record count from response, one way to do is to check the length of the array in which you are pusing the entities.
var requestBody = '{"entityName": "' + search_term + '", "maxRecordsToReturn": 100}';
var request = new sn_ws.RESTMessageV2('global.sentinel_new', 'GetSearchEntity');
request.setRequestBody(requestBody);
var response = request.execute();
var headers = response.getAllHeaders();
for (var i in headers) {
gs.info('123: '+headers[i].name + ': ' + headers[i].value);
}
var responseBody = response.getBody();
var JSONData = JSON.parse(responseBody);
for (var i = 0; i < 100; i++) {
entitiesArr.push({
'gisid': JSONData.entities[i].entity.entityID,
'entity_name': JSONData.entities[i].entity.fullBusinessName,
'stateCode': JSONData.entities[i].entity.address.stateCode,
'countryCode': JSONData.entities[i].entity.address.countryCode,
'duns': JSONData.entities[i].entity.duns
});
if(entitiesArr){
gs.info(entitiesArr.length); //Give the count of number of records in response
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 02:54 AM
Hi @Sandeep Rajput ,
entitiesArr length is same as the value (i-1) ie 99. Every time it will be 99 only.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 02:58 AM
@Ankita Kolhe This is 99 as your API returns maximum 100 records
"maxRecordsToReturn": 100
If you wish to get the exact number of records returned by the search term then you need to request your API team to check if any response parameter contains the count of total number of records.