- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2019 03:50 PM
We have a simple catalog item with a few sections. I also have an embedded widget that is using the g_form API to interact with the form.
If I call:
var sections = g_form.getSectionNames();
console.log(sections)
I correctly get a list of all the sections, but when I try to hide or show a section, nothing works
g_form.setSectionDisplay(sections[0], false);
I have tested this with about a dozen different sections, in multiple scopes, and in both London and Madrid, and no matter what I do, this method does not seem to work. It's is documented as working in Service Portal with some defects being fixed in Madrid, but I'm not able to get it to work at all.
When I inspect $scope, it looks like it correctly set "visible" to false, but nothing on the form updates.
Any suggestions?
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2019 07:37 PM
Hey Nathan,
Try just using the setDisplay method instead of the setSectionDisplay.
g_form.setDisplay(sections[0], false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 05:03 AM
@ChrisBurks For me its not working.
I am getting console log correctly but also not hiding my section in portal
Onload client script
UI Type = ALL
function onLoad() {
var sections = g_form.getSectionNames();
if(g_form.getValue('category') == '08674ad11b5624dd0dd89073be54bcbf2'){
g_form.setDisplay(sections[3], true);
}
else
g_form.setDisplay(sections[3], false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2023 05:21 AM
One difference that I notice is that it looks like your script is within an Onload client script and is executing when that script is loaded. This is fine if the script isn't loading before the section is actually loaded into the DOM.
Check to see if it works in a different type of client script like on an onChange or try wrapping it within a setTimeout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2019 01:36 PM