how to use gel in servicenow

shank1
Tera Expert

Hi all,

I wanted to know how to make use of gel in servicenow.

Some of the lines I have come across:

1.
com = gel("activity-stream-comments-textarea"); if (com) com.focus(); return;

2. gel('sysparm_item_guid').value

so I wanted to know what are those values "activity-stream-comments-textarea" and ''sysparm_item_guid'"

how and where those values can be found and used.

any other simple example to make use of gel would be greatly helpful

 

thanks in advance 🙂

 

 

 

1 ACCEPTED SOLUTION

Paul Curwen
Giga Sage

Hi Shanks,

 

Rahulpandey is correct in stating that use introduces risk to future upgrades and be aware that that getElementbyID(''element') will not work in Service Portal at all, so you should not use it for Catalog Scripts etc.

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/concept/uns...

So avoid using if you can but if you absolutely must, then see these useful articles for full description of use/issue:

https://snprotips.com/blog/2017/7/21/how-to-enable-dom-manipulation-in-the-servicenow-service-portal

http://www.snc-blog.com/2011/03/03/altering-the-dom-document-object-model-with-javascript/

 

Regards,

 

Paul

 

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

View solution in original post

9 REPLIES 9

One last question on this topic:

I see this line written :

var sys=document.getElementById('sysparm_attachment_cart_id').value;

How can I know what is that field "sysparm_attachment_cart_id" (reverse way 🙂 )

@paul.curwen did you get a chance to look at my question 🙂

 

Hi Shanks,

What is the use case you are trying to pull out the reverse way here ?

In short it is not feasible because uneven element architecture and because of the fact, it may not be even a form element(hidden field like guid). 

 

Hi Paul

The first link you posted no longer works (no surprise, it's been years).
However, The ServiceNow documentation uses gel in their dot walking example in their own documentation.
https://docs.servicenow.com/bundle/rome-platform-user-interface/page/use/navigation/reference/dot-walking-examples.html

Been there since New York.

Also, I just used it in a Catalog Client script. I had to add the Isolate script field to the form and uncheck it first, to use it.

Thanks for your insights,

Dave

shank1
Tera Expert

Thanks Paul, that is what I was looking for until now. 🙂