Thursday, February 4, 2016

Multiple Server Deployment CRM 2015

Multiple Server Deployment


As the Microsoft Dynamics CRM infrastructure requirements become more complex, careful planning will be needed to scale properly and effectively.  Server configuration options extend to all components of the deployment. Review the documented plan for any multi-server configurations so that as installation progresses all CRM components are properly configured:
  • Windows and network load balancing
  • SQL Server database redundancy options to make sure the desired option is configured  and setup clusters if needed
  • Microsoft Dynamics CRM Application Server(s)
    • Front End, Back End
    • Server Groups and Roles
    • Email Router Server(s) configuration
    • Active Directory Federation Service 2.0 Server(s) setup
      • May install 2 or more ADFS servers and configure with NLB
      • ADFS Server farm is also an option including an ADFS proxy server in a DMZ
      • SharePoint Server(s) or server farm

Deployment Design Diagram

This diagram (Figure 1) of Microsoft Dynamics CRM infrastructure shows layouts from small to medium size organization. The second diagram (Figure 2) is an enterprise deployment that demonstrates the typical scaling of servers for redundancy.
Multiple Server Deployment
ser4

Architecting Server Roles

It’s important to understand the strategies of when and how to deploy server roles for performance and scale.
There are four CRM Server Role groups:
  • Full Server – represents all CRM Server roles
  • Front End Server – Client Applications and Supported Customizations
    • CRM Web Application
    • CRM Help Files
    • Discovery and Organization Web Services
    • Back End Server – Asynchronous events processing
      • Async Services (workflow, bulk email, data imports)
      • Sandbox Service (isolation of custom code/plugins)
      • Deployment Administration Server – admin tool for managing server roles
        • Deployment Manager Tool
        • Multi-tenancy configuration
        • Windows PowerShell cmdlets
        • Deployment Web Service
        • Deploying server roles
When to scale
Additional server requirements will most likely be driven by business load and activities. Fortunately, CRM Application servers are relatively easy to scale after initial deployment if necessary.
  • Front end servers: Load balance with Windows NLB or a hardware load balancer
  • Back end servers: Load will be split automatically
Adding more hardware is often the first reaction however, there are other points to consider:
  • Number of users per front end server
  • Volume of asynchronous activity
  • Examine network traffic for potential non-CRM bottlenecks

Wednesday, January 6, 2016

Impersonation explained

When utilizing� CRM Portals for Microsoft Dynamics CRM , there are many things you will consider as you begin to implement. How you connect to Dynamics CRM is one of those important decisions.
In most typical portal implementations, a service account is used to connect to CRM.  This is the account that reads and writes all needed data to CRM.  This also means that when any record is created or updated through the portal, the records gets stamped with this service account user.  This is typically ok, but there are some cases where we do not want the record being created with the service account user name but with a specific� CRM user .
For example, one scenario may be where we are creating opportunities via a portal.  In such a case, perhaps in addition to being owned by a sales person, we want the created by to also reflect this sales person.
This can be achieved by using impersonation.  There are the two steps needed to impersonate in Microsoft Dynamics CRM:
  • The user (impersonator) must have the ActOnBehalfOf privilege or be a member of the PrivUserGroup group in Active Directory
  • Setting the CallerId property of the organization Web service proxy. Please find below a sample code that shows how to set the caller id of the organization service proxy
Impersonate in Microsoft Dynamics Crm
Note: the SystemUser is custom class we created for accessing system user entity fields in crm and CrmService is another custom class we created for creating an instance of organization service proxy

Taken from -  

http://www.powerobjects.com/2012/08/06/how-to-impersonate-in-microsoft-dynamics-crm/
 

Saturday, December 12, 2015

Clone Record

http://thinkingincrm.blogspot.com/2013/07/clone-record-via-javascript-crm-2011.html

Clone an entity record via JavaScript (CRM 2011)

We have had the need to clone a record with client-side Scripting, responding to a click on a button in the entity's Ribbon.
Conceptually the operation is easy and is based on the retrieving of all the record information using the Organization web service, then build an object identical to the first and use the web service to create a new record with this object.
Few things are important to take in mind:
1. In the building of the object the record ID must be "skipped" because, obviously, we can't create a record with an existing Guid
2. Date fields are returned in a format like: "Date("date_string") that it is not accepted in record creation from the Organization web service: depending of the need of every field, we decided to "skip it" or "reformat it". In the sample code we show both of these cases.
3. StateCode and StatusCode should be skipped (or managed) because, natively, Organization web service doesn't allow the creation of a record in a closed state.


function cloneRecord(serverUrl, originRecordType, originRecordGuid) {
    var cloneData = {};
    var activityId;
    var serverUrl = document.location.protocol + "//" + document.location.host
                    + "/" + Xrm.Page.context.getOrgUniqueName();
    var oDataUri = serverUrl + "/xrmservices/2011/OrganizationData.svc/" +  
                   originRecordType + "Set?$select=*&$filter=<EntityId> eq guid'" 
                   + originRecordGuid + "'";
    jQuery.support.cors = true;
    jQuery.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        datatype: "json",
        url: oDataUri,
        async: false, //Synchronous operation 
        beforeSend: function (XMLHttpRequest) {
            //Specifying this header ensures that the results
              will be returned as JSON.           
            XMLHttpRequest.setRequestHeader("Accept", "application/json");
        },
        success: function (data, textStatus, XmlHttpRequest) {
            if (data && data.d && data.d.results) {
                cloneData = data.d.results[0];
                //Here insert the code to skip/transform fields such as 
                  Record Id, Date fields, etc..
                replacer = function (key, value) {
                    if (key == "ModifiedOn" || key == originRecordType + "Id" ||
                        key == "CreatedOn" || key == "StateCode" ||
                        key == "StatusCode") {
                       
                        return undefined;
                    } else if (key == "ActualStart" || key == "ActualEnd") {
                        if (value) {
                            var date =
                            eval('new ' + 
                               value.replace("/", "").replace("/", ""));
                            return date.format('yyyy-MM-dd'); //Format the date
                        }
                    }
                    else return value;
                }
                //Create new Activity
                var oDataUri = serverUrl +
                               "/xrmservices/2011/OrganizationData.svc/" +
                               originRecordType + "Set";
                jQuery.support.cors = true;
                jQuery.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    datatype: "json",
                    url: oDataUri,
                    async: false, //Synchronous operation 
                    data: JSON.stringify(cloneData, replacer),
                    beforeSend: function (XMLHttpRequest) {
                        //Specifying this header ensures that the results will be
                          returned as JSON.           
                        XMLHttpRequest.setRequestHeader("Accept",
                                                          "application/json");
                    },
                    success: function (data, textStatus, XmlHttpRequest) {
                        if (data && data.d) {
                            activityId = data.d.ActivityId;
                        }
                    },
                    error: function (XmlHttpRequest, textStatus, errorThrown) {
                      alert("Error :  has occured during creation of 
                              the activity "  + originRecordType.text + ": " +
                             XmlHttpRequest.responseText);
                    }
                });
            } else {
                //No data returned
            }
        },
        error: function (XmlHttpRequest, textStatus, errorThrown) {
            alert("Error :  has occured during retrieving of the activity "
                    + originRecordType.text + ": " +
                    XmlHttpRequest.responseText);
        }
    });
    return activityId;
}

Retrieve connections from a record, filter them on the name of the connection role and send email

Validation on Special Message(Qualify)