Client Script not working on Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2017 10:03 AM
Hi Experts,
I understood, that normal client scripts will not work on service portal ... I also found some posts regarding this issue, but I don't get it. How to achieve ... you anyone please tell me in more detail what to do?
My on client scripts is something like this ...
function onLoad() {
if (g_form.getUniqueValue() !== g_user.userID)
{
g_form.removeOption('u_abc', 1);
g_form.removeOption('u_def', 1);
}
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 02:02 AM
Hi Vem
Let me try to help you. Quick question.
Could you please show me with a snapshot the widget that should be affected by the code ?
Cheers
R0b0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 02:40 AM
Just checked with him. Can not influence.
But he said, that to his knowledge only catalog client scripts do work on SP not "normal" client scripts ... true?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 02:50 AM
Hi Vem
Client scripts created on the back end (onChange, onLoad etc) work in service portal if you use the 'form' widget.
In that case the system renders the original form in the portal executing any script available.
On the other hand if you use a different widget that is not replicating the original form the code won't be execute.
Plus i don't think you can use the usual methods inside of a 'client controller'.
For instance on this widget the script we were discussing won't affect any of the fields.
Cheers
R0b0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2017 06:48 AM
So ... we use the FORM Widget ... but my client script does not seem to work ...
function onLoad() {
if (g_form.getValue('u_xxx') !== 'true') { // if not true
g_form.setDisplay('u_xxx', false); // Hide
}
UI Type is "ALL"
THANK YOU !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2017 08:10 AM
Hi Vem
Could you please try to put a couple of alert
function onLoad() {
alert('u_xxx is ' + g_form.getValue('u_xxx'));
if (g_form.getValue('u_xxx') !== 'true') { // if not true
g_form.setDisplay('u_xxx', false); // Hide
}
}
Other small thing. If your field is a boolean i would suggest to cast it as String.
g_form.getValue('u_xxx').toString() !== 'true'
because your syntax !== check the content and the type as well is not just !=
Cheers
R0b0