Is it possible to only allow certain users to re-open opportunity records after they have been closed? If yes, how?
Thanks!
Is it possible to only allow certain users to re-open opportunity records after they have been closed? If yes, how?
Thanks!
Hi Tigiard,
There is a easy and quick way to do it:
Create a javascript web resource with code below and fire it at form onLoad event:
function hideReopen(executionContext) { // in v8.x // var userName = Xrm.Page.context.getUserName(); // var formType = Xrm.Page.ui.getFormType(); // if (formType == 3 || formType == 4) {} // in v9.x var formContext = executionContext.getFormContext(); var formType = formContext.ui.getFormType(); if (formType == 3 || formType == 4) { var userName = Xrm.Utility.getGlobalContext().userSettings.userName; var allowedUsers = ['Adam', 'Ben']; if (allowedUsers.indexOf(userName) < 0) { var cssRules = 'li[aria-label="Reopen Opportunity"] { display: none!important; }'; var styleElement = document.createElement('style'); styleElement.appendChild(document.createTextNode(cssRules)); parent.document.getElementsByTagName('head')[0].appendChild(styleElement); } } }
Because there is specific attribute for the button container: a li element with aria-label="Reopen Opportunity",
thus we could call Xrm.Utility.getGlobalContext().userSettings.userName function to get current user name,
while check whether it could match an existing user name item in a users array, then insert a css rule with attribute selector to hide the button.
(It will only insert css rule on page when the opportunity is closed)
Note:
1. If you work with commented code, then you could just paste my check function inside if block(remove the original), and fire it at form onLoad event.
2. If you work with code directly without modification, then you should enable Pass execution .. option for the function.
You could also achieve it with Ribbon Workbench, it will totally disable the button when condition not meets,
but it seems that Re-open button in UCI is hard to locate from my test.
Regards,
Clofly
Yes , its possible ..
As suggested by Kunal you can write hide/show logic for that button . or any custom java script to validate it by using user security role or any parameter and popup alert on click on that
you can Modify the display rule for the button to show only for certain user usualy user of certain business unit probably by using https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/attributes/getuserprivilege
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156