- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 08:28 AM
Hi all,
what's the easiest way to pass (embed / force) server-side information into a Glide form?
The background of the question is,
I want to enable/disable a control in the form sys_user_grmember depending on the type of the group. (Group type is notoriously a list of records in table Group Type).
Best if I don't have to operate with type sys_id but rather with type name.
Querying this information on the client side is a nightmare, I have to find out first sys_id of the group type in question, then get reference to the group (remember, we are in sys_user_grmember so group.type is not available straight away), and finally enable/disable my control based on the list search result.
It feels somehow complex. I'd rather force some data into the form at the server side, before the form gets loaded, and then just use this data in the form directly, without roundtrip to the server.
Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 08:30 AM
If the server information is NOT dependent on changing information on the client (e.g. push it once and forget it) then your best bet is with the g_scratchpad object. Set the properties in a display business rule, then the client script has access to the same properties.
Docs: Client Scripts
Client Script Best Practices - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 08:30 AM
If the server information is NOT dependent on changing information on the client (e.g. push it once and forget it) then your best bet is with the g_scratchpad object. Set the properties in a display business rule, then the client script has access to the same properties.
Docs: Client Scripts
Client Script Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 08:32 AM
Use an onDisplay business rule and pass a value to the scratchpad, you don't need to store anything on the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 08:59 AM
Thanks mates, looks like it's the only way, although I don't really feel comfortable... adding code to every query to a table... you know what I mean.
Waiting for a while, perhaps yet another approach comes up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 10:14 AM
hope this can help
in client Script:
var grp = g_form.getReference('group');
//alert("BS: "+BS.u_documentation);
if( grp != undefined )
{
if(grp.grouptype == 'primary')
{
//enable/disable your control ;
}