What is the limit to DOM manipulation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello everyone,
I know that DOM manipulation is a highly discourage way to try and manipulate the DOM as future release may and can break the DOM process as it replace the DOM instead of adding on.
However, I notice that there are some class that are custom such as <sn-search-genius-card-assist>. I'm wondering are they safe from the bad effects of DOM manipulation? How much of the limit I can push? Or, are they more susceptible to be replaced by DOM as they are customer class from ServiceNow?
Thank you all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @trangdan106 ,
As per my understanding there isn't a specific ServiceNow-defined "limit" such as "you can manipulate 5 DOM elements but not 10." The limit is really about how tightly your code depends on ServiceNow's rendered HTML.
But it also recommends avoiding DOM manipulation where possible because of maintainability and upgrade risk.
Refer this :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi, thank you for the link, it was really helpful but would custom SNOW elements such as <sn-search-genius-card-assist> be less affected by changes made when ServiceNow upgrades?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
there are some requirements which you can't do without DOM manipulation
if customer wants that requirement, you need to do that and inform the impact of DOM manipulation
No limit as such it all depends on customer requirement and the script you are using
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @trangdan106
You should avoid DOM manipulation in ServiceNow as much as possible because it directly accesses HTML elements, which can break during platform upgrades. Using methods like document.getElementById() or jQuery etc makes scripts fragile and unsupportable, as ServiceNow frequently updates UI structure.
There is no limit to use it.
Few business requirement we receives too which is feasible only using DOM . In those cases, most of the time, after conveying the impact to them ,business agrees to not to proceed further, sometimes not.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
