THIS IS WORKING !!! SOLVED
If your list or library is having more than 5000 items, then you need to perform a repeated ajax call function filtering 5000 items each time.
But to know how many times to call the ajax function, we must do in Dynamic way.
- First call a ajax function with parameters "/_api/Web/Lists/GetByTitle(ListName)/Items?$orderby=Id desc&$top=1". Now you will get the latest added "Id".
- Now Divide the Id returned by the ajax by 5000. (Id/5000) So that you will get a result of how many times you need to perform the ajax.
- Now you can perform the ajax function repeatedly be filtering every 5000 items, with filter like,
$filter=Id ge 0 and Id le 5000, $filter=Id ge 5000 and Id le 10000, ........ , etc.
- You can have a foreach loop to perform the ajax repeatedly with a dynamic filter,
$filter=Id ge (5000*LoopValue) and Id le (5000*(LoopValue+1)).
Also make sure, the ajax to have async:true, to avoid performance issue. You can store the returned data in array and perform further actions, so that you could store more than 5000 data to perform your functions.
Since, there is a threshold limit for there kinda issues, we could use this kind of alternatives to make it possible.