- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:41 AM
Hi All
I have been looking on the forum and I cant see a solution for what I am trying to achieve on a catalog item.
I am trying to hide a variable on the Portal Form if the user has a role, but the suggestions I have tried and tried to tweak do not work.
Here is my script:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:58 AM
do this
function onLoad() {
if (g_user.hasRoleExactly('New_starter_vip_colleague'))
g_form.setDisplay("colleagues_name",false);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:45 AM
You should not use "return" in second line as next line code will not run.
Can you try this..!!
function onLoad() {
if (g_user.hasRoleExactly('New_starter_vip_colleague')) {
//you need to make mandatory false if they are mandatory
g_form.setMandatory("colleagues_name",false);
g_form.setVisible("colleagues_name",false);
}
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:58 AM
do this
function onLoad() {
if (g_user.hasRoleExactly('New_starter_vip_colleague'))
g_form.setDisplay("colleagues_name",false);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:45 AM
Thank you once again Ankur 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 07:40 AM
Glad to help.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader