Alternative to DOM

aswinsiddaling2
Kilo Guru

Hi All,

Currently I have a functionality where the number of attachments are suffixed next to the Paper Clip icon in any task record. This is done using a DOM manipulation in a onLoad client script as shown below.

var iconElement = document.getElementById('header_add_attachment');

iconElement.innerHTML = g_scratchpad.num;         //This scratch pad value comes from an on display business rule

And this is how the icon looks

Screen Shot 2017-02-02 at 5.20.48 PM.png

Is there any way to achieve this functionality apart from DOM? Please let me know

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Aswin,



Yes this is possible only through DOM. may be you can use gel() instead of document.getElementById. Internally gel is using the same thing.


One other way is using jquery library.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Can you provide some information about using jquery library (or) point to any documents about it?


Hi Aswin,



For using jquery in servicenow you will have to create 2 ui scripts and copy paste the script from jquery libraries. But your requirement can be achieved using gel() so it's just that if you want to learn how to use jQuery in servicenow then you can try it in your demo instance and not in client instance.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Aswin,



I hope you were able to achieve your requirement? If yes then please mark the answer as correct, helpful and hit like. This helps in closing the thread for the question. Thanks in advance.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader