Difference between g_form.getUniqueValue(); and gel('sys_uniqueValue').value;

Attila Beregvar
Tera Guru

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!

1 ACCEPTED SOLUTION

Jorn van Beek
Tera Guru

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).

find_real_file.png

View solution in original post

6 REPLIES 6

Jorn van Beek
Tera Guru

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).

find_real_file.png

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.

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.

Saurav11
Kilo Patron
Kilo Patron

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

find_real_file.png

Please mark answer correct/helpful based on Impact