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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2023 07:26 AM
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 04:54 PM
I created the same property for my scoped application, but it did not fix the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 04:59 PM
It worked after I cleared cache. Thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 09:44 PM
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