I would like to Enable/Disable a Staff Only accordion based on current user, but only if the current user has an email address that ends in @contosso.com All other users cannot use or see the Staff Only accordion.
Fellow Community Member "smithme" has a post that suggests I may want to check against this:
web.currentUser
And I have successfully used the show/hide function, and also the enable/disable function, but I am not sure how I would combine the two.
//This shows or hides Staff Only Accordion
fd.spRendered(function() {
function enableOrDisableAccordionTabs() { if (fd.field('web.currentUser').value == '*.@contosso.com') { // Enable Staff Only Accordion fd.container('Accordion2').$children[0].disabled = false; } else { // Disable Staff Only Accordion fd.container('Accordion2').$children[0].disabled = true; } } // Calling enableOrDisableAccordionTabs when the user changes CurrentUser fd.field('web.currentUser').$on('change',enableOrDisableAccordionTabs); // Calling enableOrDisableAccordionTabs on form loading enableOrDisableAccordionTabs();
});
I use this CSS with the JS to hide all Disabled Accordions
.accordion .disabled{
display: none; /* disabled children don't show up */
}