I’ve come across a few instances where I do a simple GET API call on a grid and it returns nothing, i.e. records: [].
This is the test code I use. It simply finds the first table in the page and returns the data from its first record.
const sceneKey = Knack.router.current_scene_key;
const viewId = document.querySelector('.kn-table.kn-view').id;
const recId = document.querySelector('#' + viewId + ' .kn-table-table tbody tr').id;
console.log('sceneKey =', sceneKey);
console.log('viewId =', viewId);
console.log('recId =', recId);
var apiURL = 'https://api.knack.com/v1/pages/' + sceneKey + '/views/' + viewId + '/records/' + recId;
$.ajax({
url: apiURL,
type: 'GET',
headers: {
'Authorization': Knack.getUserToken(),
'X-Knack-Application-Id': Knack.application_id,
'X-Knack-REST-API-Key': 'knack',
'Content-Type': 'application/json',
},
success: function (data) {
console.log('Success:', data);
},
error: function (response) {
console.log('Error:', response);
},
});
When I run this in the console window of various pages, apps and accounts, I get normal results most of the time, but sometimes I get the zero output bug in about 10% of the cases.
Does anyone have this problem also, and is there a pattern? So far I see nothing special with those views.
This prevents the KTL’s Bulk Edit feature to work properly for some users.
Normand