- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 03:42 AM
Dear Community,
Please help me to understand what is the difference between gel('sys_uniqueValue').value; and g_form.getUniqueValue();
I have an OOTB UI action (client side) in my personal developer instance on a related list of a form, where the script was fully untouched, but it stopped working for some reason - nothin happens if I click on it.
In the ootb script, this line is used: var sysId = gel('sys_uniqueValue').value;
I managed to debug, that if I change this line to: var sysId = g_form.getUniqueValue(); it works again.
So what is the technical difference between the 2, and why could it be that the first version stopped working?
Thanks!
Solved! Go to Solution.
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 03:52 AM
gel is short for document.getElementById maining this is default javascript.
The g_form.getUniqueValue() is a ServiceNow function.
By default gel is no longer prossible for new client scripts since manipulation of the document is no longer allowed (can switch it on, on a per script basis).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 03:52 AM
gel is short for document.getElementById maining this is default javascript.
The g_form.getUniqueValue() is a ServiceNow function.
By default gel is no longer prossible for new client scripts since manipulation of the document is no longer allowed (can switch it on, on a per script basis).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 04:00 AM
Thanks! Can it mean that if the "gel" function is used in an OOTB script written by ServiceNow (e.g. in Orlando Release), it is a bug and should be fixed? Or even it is already fixed in later releases?
In my case, I'm talking about the Create Baseline UI action on the planned_task_baseline table, which still has the "gel" function called in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 04:11 AM
No, gel is a javascript function, not a ServiceNow funtion.
the ServiceNow programmer should have used g_form not gel in his/her coding. However I can understand you would use gel if you are new to ServiceNow but not new to Javascript coding.
ServiceNow did limit the use of dom manipulation because if security issues that might occure if used incorrectly.
The option has been limited a long time already. I believe it was in Kingston, but I could be a version off.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 04:17 AM
Hello,
I do not think it is a bug as if you want to do DOM manipulation for example in Client script or UI action, you can just make the isolate script checkbox false
If you do not see it on the form just goto form layout and bring the checkbox and make it false
Please mark answer correct/helpful based on Impact