on UI Action what the technique can replace a DOM manipulation technique 'gel()' , please see on my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 02:55 AM
Description
Avoid Document Object Model (DOM) manipulation if possible. It can cause a maintainability issue when browsers are updated.
Instead, use the GlideForm API or consider a different approach for the solution. In general, when using DOM manipulation methods, you have to reference an element in the DOM by id or using a CSS selector. When referencing out-of-box DOM elements, there is a risk that the element ID or placement within the DOM could change thus causing the code to stop working and/or generate errors. While we are not saying this should never be done, it needs to be done with forethought, caution, and a full understanding of the risk you are incurring. It is recommended to review these objects and reduce the use of DOM manipulation methods as much as possible.
How can i edit script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 03:00 AM
What value are you trying to get from the form? if it's the sys_id of the record then you can use g_form.getUniqueValue()
if it's something else, there is also a function called g_form.getControl() which might help as well.
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#getControl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 03:29 AM
Can i replace line 4?
function u_print_contract() {
var features = "resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=yes,location=no";
var href = [];
href.push('sysparm_id=' + gel('sys_uniqueValue').value);
win = window.open("/u_print_contract.do?sysparm_stack=no&" + href.join("&"), "Printer_friendly_format", features);
win.focus();
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 03:31 AM
href.push('sysparm_id=' + g_form.getUniqueValue());
if it is the sys_id of the record that you are trying to put into the sysparm_id value.