Monday, February 13, 2017

Error : Too many entities enabled for auto created access teams.



Error Log: 

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Too many entities enabled for auto created access teams.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147187918</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
  <Message>Too many entities enabled for auto created access teams.</Message>
  <Timestamp>2017-02-13T21:33:05.6114604Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText i:nil="true" />
</OrganizationServiceFault>


Solution: 
In MS CRM by default you can enable for auto create access teams to Maximum 5 entities. Once this limit reaches you will see above error message.
This limit is specified in MaxEntitiesEnabledForAutoCreatedAccessTeams deployment setting.
You need to update this deployment setting if you have more than 5 entities.

To update you can use Powershell

Add-PSSnapin Microsoft.Crm.PowerShell
$Cred = Get-Credential
$CrmOrgs=Get-CrmOrganizations -serverUrl https://< CRM_Server_Host >
 -Credential $Cred
Get-CrmSetting -SettingType TeamSettings
$set =Get-CrmSetting -SettingType TeamSettings
$set.MaxEntitiesEnabledForAutoCreatedAccessTeams = “6”
Set-CrmSetting -Setting $set
 
Useful links for PowerShell:
https://technet.microsoft.com/en-us/library/dn905215.aspx#BKMK_changemon
https://technet.microsoft.com/en-us/library/dn531194.aspx
https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.deployment.teamsettings.maxentitiesenabledforautocreatedaccessteams(v=crm.7).aspx 

To Update using SQL
Login to SQL server
Run following query on MSCRM_CONFIG database
select * from DeploymentProperties where ColumnName ='MaxEntitiesEnabledForAutoCreatedAccessTeams'

To Update MaxEntitiesEnabledForAutoCreatedAccessTeams  setting run
update DeploymentProperties set IntColumn = 6 where ColumnName ='MaxEntitiesEnabledForAutoCreatedAccessTeams'

Verify your setting is changed or not using select query.
Now you can able to enable 6th entity for auto create access team. 

Tuesday, February 7, 2017

Add custom portal into online CRM

To add custom portal into online CRM

1.  Go to Admin portal, either from dynamics CRM or directly into Admin portal.


2. Then go to Admin Centers and click on Dynamics 365, as shown below

3. Dynamics 365 Administration Center will be opened in new window. 


4. Click on Applications tab in Administration Center.

5. Select Portal Add-On and click on Manage, new window will be opened to configure portal

6.  Configure your portal, by entering name, portal type (Production / Trail), portal URL. 

7. Then select Dynamics 365 instance

8. Once Dynamic 365 instance selected, you need to select portal language, portal administrator  

When selecting portal administrator 
  •  Portal Administrator must be CRM user with System Administrator role.
  • User added as contact in CRM with Web role "Administrator" 
  • Login to the portal using "Sign in with an external account" option with user CRM credentials. 
9. Then select portal Audience and how portal deployed. 


Portal audience once set for portal cannot be changed later from UI. Portal choices are tailored based on the selection of the audience.

For Partner / Employee audiences, user license required for internal users (customer employees, contactors, agents) dependent on entities exposed.

Depending on audience, we will get different options for portal to be deployed. 

10. Submit your request.

11. After submit and accept page, provisioning begins. You will see following screen


12. Once you accept, portal creation request will be submitted.

 It will take around 30 minutes to complete. After provisioning package installation begins.


13.  Once package installation completed you will see portal details, and you are ready to configure your portal. 



 14. In your CRM instance you will see one area for portal, you can manage your custom portal from there. 









Monday, February 6, 2017

Show CRM entity form to particular Business unit users only

In MS CRM we can enable security role to custom forms, and only selected role users can view that form. When selecting role, all Roles are shown form ROOT business unit, there is no option to get security role from child business units.

In some cases if you want to show custom entity form only for particular business unit users regardless of their role, then need to write custom JavaScript code.

Add following function for entity form, which want to show based on business unit, if users business unit is not allowing to view form, then user will be redirected to other form.

var accountScript = {
    showFormBasedOnBusinessUnit: function () {
        var userId = Xrm.Page.context.getUserId();
        userId = userId.replace("{", "").replace("}", "");
        var req = new XMLHttpRequest();
        req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/systemusers(" + userId + ")?$select=_businessunitid_value", false);
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
        req.onreadystatechange = function () {
            if (this.readyState === 4) {
                req.onreadystatechange = null;
                if (this.status === 200) {
                    var result = JSON.parse(this.response);
                    var businessunitid = result["_businessunitid_value"];
                    var businessunitidname = result["_businessunitid_value@OData.Community.Display.V1.FormattedValue"];
                   
                    if (businessunitidname != "Finance") {
                        var forms = Xrm.Page.ui.formSelector.items.get();
                        for (var i in forms) {
                            var formname = forms[i].getLabel();
                            if (formname == "Information") {
                                forms[i].navigate();
                                break;
                            }
                        }
                    }

                } else {
                    Xrm.Utility.alertDialog(this.statusText);
                }
            }
        };
        req.send();
    }

};