Monday, July 30, 2018

Call an external WCF service from a custom workflow or a plugin in MS CRM



Call an external WCF service from a custom workflow or a plugin in MS CRM

As we know very well custom workflow and plugins are the class libraries and obviously there is no configuration file associated with class libraries projects and that is the reason we have to follow below approach to call an external WCF service from the plugin or workflow.

First of all a proxy file needs to be generated using svcutil.exe. This command needs to execute from the command prompt. To generate the proxy file, navigate to the location of the svcutil.exe on the machine (C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools) and execute the following:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools>svcut
il.exe /language:cs /out:proxy.cs /config:app.config <SVC Service>

After executing the command a proxy.cs file is generated at the location of the svcutil.exe. This proxy.cs should be included in the workflow or plugin solution. 

Once the generated proxy.cs file added into the project, for the bindings of WCF service below code should be written where you wanted to call the service.

 
  BasicHttpBinding serviceBinding = new BasicHttpBinding();
  serviceBinding.Name = "<Binding Name>";
  serviceBinding.Security.Mode = BasicHttpSecurityMode.None;
  serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
  serviceBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
  serviceBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
  EndpointAddress endPointAddress = new EndpointAddress("http:<ServiceURLPaTH>.svc");
  ServiceClient serclient = new ServiceClient(serviceBinding, endPointAddress);

Now you can use Serclient object to call the service methods.

Hope this will be helpful.

Monday, July 23, 2018

Assembly must be registered in isolation Error-

Recently my QA team has encountered the error – “Assembly must be registered in isolation” while importing the solution which contains the plug in assemblies, although everything was fine in development environment.



The reason behind the error is the user was not a Deployment Administrator, if the user is only a System Administrator in the organization, they will be forced to register plugins in the sandbox isolation mode.

Thank you.

Friday, July 20, 2018

Call After Save Event in MS CRM 365 Form


We have recently faced a problem while reloading the form after save MS CRM Entity form. Initial thought was like this is pretty simple functionality we have to achieve and will not take more time but unfortunately when we started implementing it we got stuck in iterative problems.

 We did tried using the below code which called onSave of the form-

onSave()
{
    Xrm.Page.data.entity.save();
    setTimeout(function () {
        Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
    }, 3000);
}

But unfortunately it did not worked, we even tried the same code on the success and failure callbacks of the Xrm.Page.data.entity.save() but there is no luck, most of the time it executed fail callback of the method.

After spending some time on the Google we found the below solution and it worked 100 percent-

First of all we have created a helper function to set or remove listener to internal CRM events:

function addAfterEventHandler(eventId, handler) {
    this.parent.Mscrm.TurboForm.Control
    .CommandService.get_instance()
    .addAfterCommandExecutionHandler(eventId, handler);
}
function removeAfterEventHandler(eventId, handler) {
    this.parent.Mscrm.TurboForm.Control
    .CommandService.get_instance()
    .removeAfterCommandExecutionHandler(eventId, handler);
}

After creating the helper function we have added the listener to the after save event-

addAfterEventHandler(this.parent.Mscrm.InlineCommands.Save, function () {
    Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
});


We created the web resource of the above code and loaded the same on the form of entity where we required, that's all whenever you will save the changes for the particular form it will reload the page.


Wednesday, July 4, 2018

MS CRM Owner Teams vs Access Teams

In Microsoft Dynamics CRM 2011, the Team concept that was used is now known as Owner Teams in Microsoft Dynamics CRM 2013. The new version of CRM also introduces a new team type called Access Teams. Two fundamental differences between an Owner Team and an Access Team involve ownership and sharing. As the name implies, a member of an Owner Team inherits permissions to the records because the team owns the record. Access Teams are different in that permissions are granted to the records via sharing.
Now that there are two team types, when should you use one over the other? Since owner teams are a known concept with the two previous releases of CRM, only the best practice of when to use them will be defined in comparison to access teams.
Owner Teams
  • Best where teams access high volumes of data, via ownership or business unit access
  • When a security role is required to access records scoped by a business need
  • Teams used as service scheduling resource must be owner teams
Access Teams
  • Rapidly changing team memberships
  • Allows for >1,000 team memberships per user
  • Individual record based access
  • Owner of the record allowed to define access to other users
  • Can accommodate varying levels of group access types to records

QueryExpression vs. FetchXML in MS CRM with C#

Microsoft Dynamics CRM (Customer Relationship Management) is a powerful platform that helps organizations streamline their business processe...