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

Dave Smith1
ServiceNow Employee
ServiceNow Employee

I don't... but... can't it be done using a Dictionary Override to force a particular attribute for that field, if it's an inherited one?

Yeah - I did the dictionary attribute to get rid of the knowledge search icon but I cannot find an attribute for the suggestion icon.

sachin_namjoshi
Kilo Patron
Kilo Patron

To setup a suggestion field you set the Choice value to "suggestion".   This is set on the task.short_description field that affects all tables that extend task.   You can remove it for all those tables but there isn't a dictionary override for the "choice" value.

 

Regards,

Sachin

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!