Hi,
I have a requirement to show the 'Create PO' tab only when the related entity "Work Order" contains a record - else hide.
Has anyone encountered this example before and have a sample code for me to get started? Many thanks in advance.
Hi,
I have a requirement to show the 'Create PO' tab only when the related entity "Work Order" contains a record - else hide.
Has anyone encountered this example before and have a sample code for me to get started? Many thanks in advance.
Hi,
Good to hear that it worked
Update. Got this to work:
function ShowHideMasterPOMatchPOTabs(executionContext) {
var formContext = executionContext.getFormContext();
var isRole = false;
Xrm.Utility.getGlobalContext().userSettings.roles.forEach(
role => {
if(
role?.name == "System Administrator" ||
role?.name == "*BF Field Service - Zone Manager" ||
role?.name == "*BF Field Service - Dispatcher"
) {
isRole = true;
}
}
);
formContext.ui.tabs.get("tab_4").setVisible(isRole);
}
Thanks, I did see that article but the code was not working for me. In the article above the code is hiding all related navigation items if User Security Role is not System Admin.
Basically I need the code to show the 'Match PO' Tab (tab_4) only to the roles System Admin (System Administrator), Zone Manager (*BF Field Service - Zone Manager), Dispatcher (*BF Field Service - Dispatcher), else it hides.
Any suggestions here? I've tried and am not successful thus far.
Thanks! Will check that out.
Another question is if there is a code snippet to show a tab (tab_4) if User Security Role = ("System Administrator"), ("*BF Field Service - Dispatcher"), (*BF Field Service - Zone Manager"), else hide.
I have a snippet that is not working I think because the !UserHasRole is not properly being used, or out of date.
Any thoughts or sample would be appreciated!
Hello,
Use Xrm.WebApi.retrieveMultipleRecords to check the record count in related entity
learn.microsoft.com/.../retrievemultiplerecords
Dataverse Rest builder tool can be used to generate code
Thanks! I did see some of that documentation. I have just never wrote code to show/hide tabs based on a related entity having data (as shown in my screenshot above). I'll keep digging, thanks.
Hi Chrisbra22,
Here are the helpful links:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,532 Super User 2024 Season 2
Martin Dráb 228,501 Most Valuable Professional
nmaenpaa 101,148