Could someone help me figure out what I must be doing wrong?
function hideReopenOpportunityButtonOnClosedOpportunity(executionContext) { var formContext = executionContext.getFormContext(); var opportunityStatus = formContext.getAttribute(/msdyn_forecastcategory/).getValue(); var ownerTeamId = '2df71575-2c18-ef11-9f89-6045bda21d2c'; // The specific owner team ID // if (opportunityStatus === 100000005) { var currentUserId = Xrm.Utility.getGlobalContext().userSettings.userId.replace(/{/, //).replace(/}/, //); // Fetch the teams the current user is a member of fetchUserTeams(currentUserId).then(function(teams) { var isMemberOfOwnerTeam = teams.some(function(team) { return team.teamid.toLowerCase() === ownerTeamId.toLowerCase(); }); if (!isMemberOfOwnerTeam) { // Hide the /Reopen Opportunity/ button hideReopenOpportunityButton(formContext); } }).catch(function(error) { console.log(error.message); }); }}function fetchUserTeams(currentUserId) { var query = //systemusers(/ + currentUserId + /)/teammembership_association/; return Xrm.WebApi.retrieveMultipleRecords(/team/, query).then(function(result) { return result.entities; });}function hideReopenOpportunityButton(formContext) { var reopenButton = formContext.ui.controls.get(/Reopen Opportunity/); if (reopenButton) { reopenButton.setVisible(false); }}
<?xml version=/1.0/ encoding=/utf-16/?><RibbonDiffXml xmlns:xsd=/http://www.w3.org/2001/XMLSchema/ xmlns:xsi=/http://www.w3.org/2001/XMLSchema-instance/> <CustomActions> <CustomAction Id=/vinu.Mscrm.Form.opportunity.ReopenOpp.CustomAction/ Location=/Mscrm.Form.opportunity.MainTab.Actions.Controls._children/ Sequence=/5/> <CommandUIDefinition> <Button Alt=/$LocLabels:Mscrm.Form.opportunity.ReopenOpp.Alt/ Command=/Mscrm.Form.opportunity.ReopenOpp/ Id=/Mscrm.Form.opportunity.ReopenOpp/ Image32by32=//_imgs/ribbon/ReopenOpportunity_32.png/ Image16by16=//_imgs/ribbon/ReopenOpportunity_16.png/ LabelText=/$LocLabels:Mscrm.Form.opportunity.ReopenOpp.LabelText/ Sequence=/5/ TemplateAlias=/o1/ ToolTipTitle=/$LocLabels:Mscrm.Form.opportunity.ReopenOpp.ToolTipTitle/ ToolTipDescription=/$LocLabels:Mscrm.Form.opportunity.ReopenOpp.ToolTipDescription/ ModernImage=/ReOpenOpportunity/ /> </CommandUIDefinition> </CustomAction> </CustomActions> <Templates> <RibbonTemplates Id=/Mscrm.Templates/ /> </Templates> <CommandDefinitions> <CommandDefinition Id=/vinu.opportunity.Command0.Command/> <EnableRules> <EnableRule Id=/vinu.opportunity.EnableRule0.EnableRule/ /> </EnableRules> <DisplayRules /> <Actions> <JavaScriptFunction FunctionName=/hideReopenOpportunityButtonOnClosedOpportunity/ Library=/$webresource:crc3e_hideReopenV2/ /> </Actions> </CommandDefinition> </CommandDefinitions> <RuleDefinitions> <TabDisplayRules /> <DisplayRules /> <EnableRules> <EnableRule Id=/vinu.opportunity.EnableRule0.EnableRule/> <CustomRule FunctionName=/hideReopenOpportunityButtonOnClosedOpportunity/ Library=/$webresource:crc3e_hideReopenV2/ Default=/false/ InvertResult=/false/ /> </EnableRule> </EnableRules> </RuleDefinitions> <LocLabels> <LocLabel Id=/Mscrm.Form.opportunity.ReopenOpp.LabelText/> <Titles> <Title description=/Reopen Opportunity/ languagecode=/1033/ /> </Titles> </LocLabel> <LocLabel Id=/Mscrm.Form.opportunity.ReopenOpp.ToolTipTitle/> <Titles> <Title description=/Reopen Opportunity/ languagecode=/1033/ /> </Titles> </LocLabel> <LocLabel Id=/Mscrm.Form.opportunity.ReopenOpp.ToolTipDescription/> <Titles> <Title description=/Reopen this opportunity to make it active and continue working on it./ languagecode=/1033/ /> </Titles> </LocLabel> <LocLabel Id=/Mscrm.Form.opportunity.ReopenOpp.Alt/> <Titles> <Title description=/Reopen Opportunity/ languagecode=/1033/ /> </Titles> </LocLabel> </LocLabels></RibbonDiffXml>