Isolate script = false and dom manipulation not working in scoped apps?

Ulf Cederholm
Tera Expert

We have a couple of onChange client scripts with DOM manipulations in our global environment. These all works as expected.


However if I try to run similar scripts in any of our scoped apps I only get the error: "onChange script error: TypeError: $ is not a function function () { [native code] }"


'Isolate scrip' is set to false on all the scripts. Also tried to add system property to turn of this security feature in both global and scoped. Works in global but not in scoped apps.

To me it seems like dom manipulation doesn't work in scoped apps but I cannot find any documentation suggesting this. This is not in any Workspaces or any forms using Next UI.


I've seen other people with very similar problems in scoped apps but so far not any proper answer. Only for similar issues in the global environment. Anyone that have a working solution for this in scoped apps?

 

Example of onChange client script below:

 

function onChange(control, oldValue, newValue, isLoading) {
var domLabel = $('label.<table>.<field>');
var domField = $('sys_display.<table>.<field>');
if (!newValue) {
domLabel.setStyle({backgroundImage: ""});
domField.setStyle({color: "", backgroundColor: ""});
g_form.removeDecoration('<field>', 'icon-success-circle', 'Test.', 'color-blue');
return;
}
g_form.getReference('<field>', domCallback);
}

function domCallback(onchangefield) {
var domLabel = $('label.<table>.<field>').down('label');
var domField = $('sys_display.<table>.<field>');
if (onchangefield.first_name == 'Ulf') {
var bgPosition = "95% 55%";
if (document.documentElement.getAttribute('data-doctype') == 'true') {
bgPosition = "5% 45%";
}
domField.setStyle({color: "blue", backgroundColor: "#f1f8fd"}); //#f1f8fd = 'very light blue'
g_form.addDecoration('<field>', 'icon-success-circle', 'Test.', 'color-blue');
}
else {
domLabel.setStyle({backgroundImage: ""});
domField.setStyle({color: "", backgroundColor: ""});
g_form.removeDecoration('<field>', 'icon-success-circle', 'Test.', 'color-blue');
}
}

3 REPLIES 3

Rajini2
Mega Sage

I created the same property for my scoped application, but it did not fix the error.

It worked after I cleared cache. Thank you so much.

Kailash Bhange
Kilo Sage
Kilo Sage

Hi All,
Please review below Article for Client Script details and mark helpful if it helps you.
World of Client-side Scripts: #1

 

Thank you!

Kailash Bhange

LinkedIn