gs.getUserID() doesn't work in agent mobile app?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 06:26 AM
In the agent mobile app I am trying to pull back all active Work Order tasks assigned to the logged in user, and retrieve their parent Work Orders. This does not work in the mobile app but it works just fine as a background script or business rule.
From the mobile app, how do I get the logged in user so I can build this query?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 06:47 AM
Hi,
You should be able to use gs.getUserID() just fine.
Check formatting:
var wot = newGlideRecord('wm_task');
to
var wot = new GlideRecord('wm_task');
Can you give a bit more information as to how it's not working?
It's also recommended to use: gs.info() instead of gs.log()
You should also be able to simply use:
var queryString = 'sys_idIN' + woList;
If the records have all been pushed correctly and it consists of a comma separated array of sys_ids (check the value in a log statement).
Here's GlideRecord documentation as well: https://developer.servicenow.com/dev.do#!/reference/api/paris/server/no-namespace/c_GlideRecordScope...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 06:54 AM
Sorry, not sure why my copy and paste wasn't 100% accurate but I do have the gliderecord line correctly set up with the space between new and gliderecord.
This is a scoped app though (for field service mobile), does that make a difference?
When I copy and paste the entire code into the background script, it returns a list of all the Work Orders that I have at least one task assigned to me from. In the mobile app, it gives me zero results in my list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 07:01 AM
Hi,
gs.getUserID() should still work in scoped application.
gs.log() however, does not work, please use gs.info() as mentioned above.
You'd want to ensure that you can access data from that other table from a scoped application. Check table settings, etc.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 08:24 AM
Hi, You may want to use a function similar to the accepted solution of this thread (in case you still have the issue):
https://community.servicenow.com/community?id=community_question&sys_id=7b40c7a1db98dbc01dcaf3231f96...