locked
Opportunities: Restrict Closing and Reopen of opportunities to Certain users RRS feed

  • Question

  • Hi,

     

    I need to restrict the reopen of oppertunities to certain CRM 4.0 users.

     

    I have revised the security roles but can'tseem to find it there.

     

    Would anyone know if this can be achieved or if there is a work-around involved.

     

    Thanks

    Friday, August 15, 2008 8:41 AM

Answers

  • Hi,

     

    Unfortunately I believe there is not out of the box privilege that let you control who can reopen opportunities.

     

    However, using a pre plug-in on the SetState of the opportunity entity you could add custom code to check if the user is in the correct role and cancel the operation if not. You can find more information about plugins on the SDK http://msdn.microsoft.com/en-gb/library/cc151086.aspx

     

    Hope it helps,

    Marco

     

     

     

     

    Friday, August 15, 2008 9:53 AM
    Moderator
  • Other than Marco's way, another way is to use Javascript (with AJAX accessing CRM Web Service) to hide the option Close Opportunity... from the Actions Menu bar.  You can add the following javascript to the onLoad of opportunity:

     

    Code Snippet

    if(WhoAmI() == "John Doe" || WhoAmI() == "Jane Doe")

    {

    var item=document.getElementById("_MIcomplete");

    if(item!= null && typeof(item)!='undefined')

    item.style.display="none";

    }

     

     

    The method WhoAmI() will perform an AJAX call to MS CRM to find out the name of the login user.  For detail implementaiton, please refer to: http://msdn.microsoft.com/en-us/library/cc150838.aspx

     

     

    _MIcomplete is the element Id of the Close opportunity action item.  Please note that this is totally unsupported code and Microsoft might change the naming convention in the future.

    Friday, August 15, 2008 5:10 PM
  • The element id is "_MIreactivate".

     

    I don't think anyone (even the people from product team) can answer this question.  If you are going to make the change, make sure you document this change in case you are no longer working on this project.

    Tuesday, October 14, 2008 4:30 PM

All replies

  • Hi,

     

    Unfortunately I believe there is not out of the box privilege that let you control who can reopen opportunities.

     

    However, using a pre plug-in on the SetState of the opportunity entity you could add custom code to check if the user is in the correct role and cancel the operation if not. You can find more information about plugins on the SDK http://msdn.microsoft.com/en-gb/library/cc151086.aspx

     

    Hope it helps,

    Marco

     

     

     

     

    Friday, August 15, 2008 9:53 AM
    Moderator
  • Other than Marco's way, another way is to use Javascript (with AJAX accessing CRM Web Service) to hide the option Close Opportunity... from the Actions Menu bar.  You can add the following javascript to the onLoad of opportunity:

     

    Code Snippet

    if(WhoAmI() == "John Doe" || WhoAmI() == "Jane Doe")

    {

    var item=document.getElementById("_MIcomplete");

    if(item!= null && typeof(item)!='undefined')

    item.style.display="none";

    }

     

     

    The method WhoAmI() will perform an AJAX call to MS CRM to find out the name of the login user.  For detail implementaiton, please refer to: http://msdn.microsoft.com/en-us/library/cc150838.aspx

     

     

    _MIcomplete is the element Id of the Close opportunity action item.  Please note that this is totally unsupported code and Microsoft might change the naming convention in the future.

    Friday, August 15, 2008 5:10 PM
  • Thanks, we were able to implement the functionality to our project

     

    Monday, August 18, 2008 5:34 AM
  •  

    Would you know what the element id  (getElementById) name is for 'Reopen Opportunity'?

     

    Although I know that this method is unsupported, what are the chances that Microsoft will change this naming convetion in future releases?

     

    Thanks.

    Tuesday, October 14, 2008 4:21 PM
  • The element id is "_MIreactivate".

     

    I don't think anyone (even the people from product team) can answer this question.  If you are going to make the change, make sure you document this change in case you are no longer working on this project.

    Tuesday, October 14, 2008 4:30 PM
  • Thanks Jude

    Wednesday, October 15, 2008 6:25 AM
  • Hi,

    just replace the "UserName" with ur username and if multiple users, just put or(||) operator and use the same.

    if(crmForm.FormType == 4){ //if the formtype is 4 means disabled(closed)
     var xml = "" +
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
     " <soap:Body>" +
     " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
     " <q1:EntityName>systemuser</q1:EntityName>" +
     " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
     " <q1:Attributes>" +
     " <q1:Attribute>systemuserid</q1:Attribute>" +
     " <q1:Attribute>fullname</q1:Attribute>" +
     " </q1:Attributes>" +
     " </q1:ColumnSet>" +
     " <q1:Distinct>false</q1:Distinct>" +
     " <q1:Criteria>" +
     " <q1:FilterOperator>And</q1:FilterOperator>" +
     " <q1:Conditions>" +
     " <q1:Condition>" +
     " <q1:AttributeName>systemuserid</q1:AttributeName>" +
     " <q1:Operator>EqualUserId</q1:Operator>" +
     " </q1:Condition>" +
     " </q1:Conditions>" +
     " </q1:Criteria>" +
     " </query>" +
     " </soap:Body>" +
     "</soap:Envelope>" +
     "";

     var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

     xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
     xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
     xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
     xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
     xmlHttpRequest.send(xml);

     //var doc = xmlHttpRequest.responseXML;
     xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
       xmlDoc.async=false;
       xmlDoc.loadXML(xmlHttpRequest.responseXML.xml);

       var fullName = xmlDoc.getElementsByTagName("q1:fullname");

     if(fullName[0].text.toLowerCase() == "UserName"){
     //do nothing for these bunch of users
     }else{  //hide the Reopen option for the rest of users
      //alert("fullName "+fullName[0].text);
      document.getElementById("_MIreactivate").style.display = "none";
     }
    }

     

    Have happy coding.

    Sudhanshu

     

    Friday, May 21, 2010 9:38 AM