- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 10:46 AM
Hello:
I have the onChange catalog client script below, on a Record Producer (Catalog Item). It works when I am logged in as an Itil user - the alert displays the correct sys_id.
However, I'd like it to work for anonymous users, but when not logged in the alert does not execute
The work_unit field on the Record Producer is public, the ACLs on the Work Unit table allow read access, and as an anonymous user I can display the work units from the portal.
I think the callback function may be restricted somehow, but not sure what else to try and would appreciate any help. Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 10:58 AM
You are indeed correct; getReference runs under the credentials of the logged in user and for unauthenticated users will not return expected results in most cases.
You would need to convert this to using GlideAjax to make the call and return the values.
You would also need to make the privacy of your script include public for a non-logged in user to be able to execute it.
I hope this helps!
If this was helpful, or correct, please be kind and mark the answer appropriately.
Michael Jones - Proud member of the GlideFast Consulting Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 10:27 AM
Thank you very much for your response. We are using custom tables, and are careful about not giving access to public data. I checked the ACLs and also stumbled upon this article:
https://community.servicenow.com/community?id=community_article&sys_id=e047d880db8c245466f1d9d968961994
I changed my getValue call to include both the display value and sys_id, as per the example in article:
g_form.setValue('location', '25ab9d720a0a0bb300793d3a6b891f82', '6304 Northwest Barry Road, Kansas City,MO');
The values in the second reference field now display even for anonymous users. So all good, at least for now. Thank you again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 10:48 AM
Hi,
Just to throw this out there, when you're supplying both the sys_id and the display value when setting a reference field:
- That's best practice and should be done in the client everytime
- It's best practice because you're saving resources from having to go back to the server anyway to find the display to then bring back to the client because you only provided the sys_id.
So with the above, you providing both the sys_id and the display value and it working, that's great. Additionally, if you set the "read" for the table to allow non-authenticated users, you may want to look at specific "read" ACLs for your fields (so not just the table level but table.field). Perhaps you have additional ACLs that are coming into play because they aren't just table level and but you have some for table.field (which then creates a table.* ACL as well). So the name field or whatever your display column is for that table, may not be accessible to the unauthenticated user.
Please mark reply as Helpful, 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
‎03-24-2022 10:58 AM
Hi @Christine;
Yes, getRefernce() method is not woking for some user session instead using getRefernce we can use GiledAjax and client callable script include.
https://docs.servicenow.com/bundle/quebec-application-development/page/script/ajax/topic/p_AJAX.html.
If this answer is helpful please mark correct and helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 02:09 PM
Thanks!