is there any alternative for document.getElementById().innerHTML in client script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 06:36 AM
I need an alternative for document.getElementById().innerHTML in client side scripting. Since the DOM is method to avoid in servicenow
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2019 06:40 AM
try with g_form.getControl('name');
Note: g_form.getControl('name') will not work on portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 01:57 AM
Hi,
Nabil
The following globals and APIs are unavailable in service portal client script:
- window
- document
- $
- jQuery
- $$
- $j
- angular
This means that if you are rendering a form in the service portal and you need to manipulate the look and feel of the form can be done on the ServicePortal side
- using a local CSS
- probably trying to work on the controller to have something similar to this
https://stackoverflow.com/questions/25738234/alternative-of-getelementbyid-in-angularjs
Thanks and Regards,
Monali Patil
Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 02:04 AM
It would be good if you describe the goal of usage document.getElementById().innerHTML in your code. If you really would need exactly document.getElementById().innerHTML, then you will don't find any better way, because all other ways (for example usage jQuery or angular) uses the same document.getElementById().innerHTML internally. Thus all alternative ways will be slowly.
On the other side if you describe your scenario (the use case) where you use document.getElementById().innerHTML and why you are not satisfied then one suggest you some alternative or to explain why the current way is the best one.