- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 08:09 AM
Hello,
I have the following record producer on Service Portal.
On backend, it looks like this:
I want to make the destination field (variable's name --> destination) invisible once the form is loaded on Service Portal.
Thus, I created the following onLoad Catalog client script, while I included a console.log statement in order to see if the script is actually running when the form is loaded.
However, when I enter on the record producer on Service Portal, I can still see the destination field (it supposed to be invisible with the catalog client script). As you can see the console.log statement works properly, but the g_form.setVisible() statement is not working.
Bare in mind that I want the destination field to be a mandatory field.
This mandatory field will be visible after, only if for example the user selects "Category A" from another choice field.
What's going wrong here? Any ideas are welcomed.
Thank you all in advance.
Regards,
Smith.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 08:16 AM
You can not hide the field as long as it is mandatory.
You can set mandatory to false and then hide it:
g_form.setMandatory('destination', false)
g_form.setVisible('destination', false)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 08:16 AM
You can not hide the field as long as it is mandatory.
You can set mandatory to false and then hide it:
g_form.setMandatory('destination', false)
g_form.setVisible('destination', false)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 08:17 AM
Hi
Few things to check
1. UI type set to All
2. You cannot hide the mandatory field without making it non-mandatory first
g_form.setMandatory("destination",false);
g_form.setDisplay("destination",false);
Mark the comment as a correct answer and also helpful once worked.