How to use DOM or Jquery in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 12:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 12:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 12:38 AM
Hello Ben,
This is working for me:
The comments text-area actually changes as you interact with it so it can have two different IDs. This version of your script simply binds the focus event to both elements and checks which is the currently active element in the event handler.
Hope this helps!
function onLoad() {
// Store the variable on load
var signatureValue ="Hello!";
//**Additional comments field can be one of two elements:
//#activity-stream-comments-textarea
//#activity-stream-textarea (initial)
var el = '#activity-stream-textarea';
jQuery('body').on('focus', '#activity-stream-textarea,#activity-stream-comments-textarea', function(e){
//dynamically set current element
var el = jQuery('#activity-stream-comments-textarea').is(':visible')
?'#activity-stream-comments-textarea':'#activity-stream-textarea';
var content = jQuery(el).val();
if(!content.length){
jQuery(el).val(signatureValue);
}
});
}
if my response helps you then kindly mark my answer helpful and correct otherwise if any query feels free to ask further.
Regards,
Ajim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 01:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 03:16 AM
Hi,
You can try this
Sample function:
var gURL = new GlideURL();
gURL.setFromCurrent();
alert(gURL.getParam("sysparm_id"));
where sysparm_id is the parameter that needs to be read from the URL.
Or you can go through the link-
Please mark correct or helpful.
Thanks
Swapnil
Both prototype and jquery can't handle id selectors that have periods (.) in them.
To get the selectors to work you need to escape (use \) the special characters. This also applies to id's that have # and : in them.
The correct prototype selector statement is :
$$('#element\.incident\.comments div').each( ....