Fuji client scripts: document object is null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2015 12:39 AM
Hi
We use document.getElementById() or gel() in client scripts to get controls. In some places we cannot replace it with g_form. For example, I need to get a catalog item sys_id in variable set client script so the only way I could do that was document.getElementById("sysparm_id").value
What I found out is that for any client script document object is null:
[Error] TypeError: null is not an object (evaluating 'document.getElementById')
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2015 11:22 AM
Luxo, you are correct.
For any scoped application that requires DOM access to forms, etc. this property has to be created in its scope and set to false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2015 09:14 AM
hi Bobby,
As you mentioned i have created the property glide.script.block.client.globals and made it true.
But still my below code is not working as in eureka.
var e = document.getElementById("label.incident.u_alternate_contact_business");
e.style.backgroundColor = '#CEF6EC' ;
thanks
Luxo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2015 08:54 AM
Please set the property to false and it should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 01:07 AM
hi Bobby,
Thanks for your Reply.But no luck this time too.
Tried with another DOM object also as below
document.getElementById('label.incident.number').style.backgroundColor='red';
I have used in onLoad Client script.In Eureka color changes to red,But in fuji no Luck .
thanks
Luxo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 10:15 AM
Luxo,
The property I provided allows you to use DOM manipulation. Beyond that you have to have a good understanding of the elements you are trying to modify to get the results you are after. I do not recommend setting styles on fields using this method because the elements and styles change frequently with releases. Something that works today may not work tomorrow as you see in the case of Eureka to Fuji. The element you are trying to set a background color on is a div which is the parent of the label element. In Fuji, the label element has classes that make it use style sheets that override styles from the parent node.
We provide the ability to style fields natively here: Defining Field Styles