Scoped App - DOM Manipulation not allowed in client script?

TrevorK
Kilo Sage

I know, I know, DOM manipulation is not recommended.

What I'm trying to do is hide the Suggestion button next to Short Description (the table is extended from task) and it does not look like there is a property to do it.

find_real_file.png

I figure I'll just do an onLoad Client Script and be done with it, making sure to test it out during the upgrades in case the id changes.

No matter what I do everything fails. window and document are both returning null, so I cannot use the typical command (e.g. document.getElementById()). jQuery ($j) commands are not working either. My scripts run on a different task table (within the global scope) work perfectly fine every time.I even tried in a UI Policy and get the same issues.

 

Does anyone know of a workaround for doing DOM manipulation within a scoped app? It's driving me crazy I cannot do it within the scoped app.

1 ACCEPTED SOLUTION

TrevorK
Kilo Sage

After talking to a co-worker he spent some time searching and we found the solution. Scoped client scripts do not have access to many of the same APIs, but it's just a simple system property (on a per application basis) to enable it:

https://community.servicenow.com/community?id=community_blog&sys_id=788c66e1dbd0dbc01dcaf3231f961969

Once enabling the system property everything works great!

View solution in original post

6 REPLIES 6

Jim Coyne
Kilo Patron

This could be an alternate workaround - "Suggestion" Tool

Your solution looks very interesting - thanks for sharing Jim!