Cannot use getReference method on client script , Glide ajax is the other way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 10:05 AM
Hi
Facing one challenge to use getReference method on client script. I know the other way is to use Glide ajax call.
But I have a display business rule and have a g_scratchpad variable.
I am having reference field "abc" on a table on which my onLoad client script is written and this "abc" field refers to other field that is having a manager field. I want the value of this manager field and needs to compare this with my g_scratchpad variable.
Pls let me know how can I use this on my client script instead of getRefernce. If Glide ajax is the way so pls provide me the logic and script for reference , how can I call my display BR on client script.
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 08:17 PM
Hi,
in onload client script access the g_scratchpad.SOM variable and compare it with what you want
something like this
function onLoad(){
var loggedInUser = g_user.userID;
if(loggedInUser != g_scratchpad.SOM){
g_form.setReadOnly('u_abc', true);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 09:04 PM
Hi Rahul,
You can use Ankur's script in client script. However, remember one thing if field is already read only for service manager because of some ACL then making it editable through client script will not work.
I would suggest to go with ACL which is quite appropriate and simple for your requirement. You would need to create "write ACL" on abc field and use below script in script section of ACL, that's it.
var answer=current.u_service_offering.owned_by==gs.getUserID();
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP