Mobile Agent offline fetch script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
When downloading the cache for offline mode, I can only retrieve up to a maximum of 1,000 users from the sys_user table. I have many more active users than this limitation. I'm looking for guidance on creating an offline fetch script under input attributes for assigned to in my create interaction function. I need to dynamically fetch the logged in user's sys ID (gs.getUserID() and return results of any records on the user table who share the same location.
I will apply this same logic to any sys_user reference field for incidents and interactions. Thanks for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Buddy,
Offline reference caching is capped at ~1,000 records, so you must filter sys_user instead of caching all
Here is the short version that works for Mobile / Now Mobile offline mode.
1) Script Include (server-side)
Create a Script Include to return active users in the same location as the logged-in user, plus the user themself.
var MobileOfflineUserFetch = Class.create();
MobileOfflineUserFetch.prototype = {
initialize: function() {},
getUsersByMyLocation: function() {
var ids = [];
var myId = gs.getUserID();
var myLoc = gs.getUser().getLocation();
ids.push(myId); // always include self
if (!myLoc)
return ids.join(',');
var gr = new GlideRecord('sys_user');
gr.addActiveQuery();
gr.addQuery('location', myLoc);
gr.setLimit(1000);
gr.query();
while (gr.next()) {
ids.push(gr.getUniqueValue());
}
return ids.join(',');
},
type: 'MobileOfflineUserFetch'
};2) Assigned To → OfflineFetchScript
On the Assigned to reference input (Create Interaction):
javascript:new MobileOfflineUserFetch().getUsersByMyLocation()
Result
Offline cache stays under 1,000 records
Users see only relevant users (same location)
Reusable for Incident, Interaction, or any sys_user reference field
@Jeff Lyons - Please Mark Accepted Solution and Thumbs Up if you found Helpful 🙂
