What does \${} do in Client Script?

scwillson
Mega Guru

I just had to copy and tweak an OOTB Client Script so that the "Highlight VIP Caller" for Incident, also worked on the Call form (new_call).

I got it to work, that is not my issue. My thing is that I like to know WHY and HOW things work, but I couldn't find any details about the lines that I tweaked to get it working.

var callerLabel = $('label.incident.caller_id');

var callerField = $('sys_display.incident.caller_id');

I quickly figured out that the later part of the lines were just identifying the table and column of which the value is being checked, but I still don't know where the "label" or "sys_display" are coming into play. Also, I am a little familiar with using the ${} to pull in pre-defined related variables within Jelly and SNOW Notifications.

I was unable to find any good documentation on this subject in SNOW.

If anybody could shed some light on this for me, give a synopsis, and/or link related documentation here..it would be greatly appreciated.

Thanks!!

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Simon,



  $() is a selector, to get the DOM element by its ID. This is part of prototype JS frame work. In simpler words it is same as gel() or getElementByID().


you can go thru this article for more details


Prototype v1.7.3 API documentation | $



In your case label.incident.caller_id and sys_display.incident.caller_id are the ID's of the elements. You can see that when you open your browser developer tools   and inspect the element as shown below


dom_elements.PNG



Thanks,


Abhinay


View solution in original post

3 REPLIES 3

HV1
Mega Guru

The outer brackets, ${}, specify the output of the variable and the phase in which the variable is output: ${} means first phase, $[] means second phase.


Reference: Content Management and Jelly - ServiceNow Wiki


Abhinay Erra
Giga Sage

Simon,



  $() is a selector, to get the DOM element by its ID. This is part of prototype JS frame work. In simpler words it is same as gel() or getElementByID().


you can go thru this article for more details


Prototype v1.7.3 API documentation | $



In your case label.incident.caller_id and sys_display.incident.caller_id are the ID's of the elements. You can see that when you open your browser developer tools   and inspect the element as shown below


dom_elements.PNG



Thanks,


Abhinay


Thanks Abhinay!!!