Monday, 21 January 2019

Business Rule in Dynamics CRM

Business rules allow for defining logic that takes place in a form. Business rules provide an alternative to form scripts because they can be defined within a user interface without writing code

 The business rule is fired when the form is loaded or updated only at the client CRM form.




ScopeWhere it runs run
EntityAll forms and server
All formsAll forms
Specific formJust that form

Here Client means the browser, if your business rules are not published using Entity, it will only run client side (browser), it does not means to specific user.
So for example I am changing something in entity form field associated with the business rule, it will fire . But if I am updating entity data using service call/SDK which do changes in server, business rule won't fire.
But in case of server side business rule, it will fire in above case.

In the top right of the form, use the Scope field to set the scope for the rule. “Entity” scope level is new in CRM 2015. Setting the scope of the business rule at an entity level, forces the business rule executed on both server and all clients side.

For example, on update of an entity record we will set “Description” field mandatory based on some conditions. So in this case we can create Business rule as below:
Business Rules #1
Business Rules #1
  • Server Side Validation

To test this business rule validation on server side, we create a real time workflow to update this record which should trigger the validation logic:
crm 2015 bpa2
Trigger the workflow from a record and get below error message immediately:
crm 2015 bpa3
The record cannot be saved due to “Business Process Error”:
crm 2015 bpa4
Download log file and we can find the trace details:

<TraceText>
[Microsoft.Crm.ObjectModelMicrosoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]
[1769c1b5-1784-e411-80c5-00155d016814: ] Starting sync workflow ‘Test Scope of Business Rule’, Id: 0e69c1b5-1784-e411-80c5-00155d016814
Entering UpdateStep1_step: Sync workflow ‘Test Scope of Business Rule’ terminated with error ‘Attribute ‘new_description’ cannot be NULL’
</TraceText>

  • Client Side Validation To test this business rule in client side, we just simply update the record on the form and the error message show up as expected:

crm 2015 bpa5
Conclusion:

To implement the same validation logic in previous CRM version, we have to develop plug-in in server side. Now CRM 2015 offers us a much simple way to apply the same logic on both server and all clients without writing coding. You can also set the rule select a specific form.
Business rules run only when the form loads and when field values change. They do not run when a record is saved, unless the scope for the rule is set at an entity level.



Limitations of Business Rule:

  • One of the limitations of business rules is that they are not executed during bulk edits and imports.
  • We can’t debug and trace business rules like we do the JavaScript.
  • The actions that can be performed using business rules are limited compared to the requirements a developer has to meet, like setting a field value by appending two other field values and hence forces them to depend on JavaScript.
  • Also business rules are launched in the order they are activated. So one has to know all the business rules and the order in which they are to be executed in an entity.
  • The number of If…Else statements in a business rule is limited to 10.
  • The execution of a business rule is always enforced. There is no control over their execution. When a JavaScript and business rule acts on the same field of a form, the precedence is for System JavaScript followed by Custom JavaScript and then business rules.
  • A JavaScript cannot be called from a business rule.
  • A business rule can be acted only on the fields of local entities and not on the fields like look up of related entities or parent entities. Also business rules can’t interact with tabs and sections.

Wednesday, 16 January 2019

Calling Java Script on click of command button MS CRM 2015

Calling Java Script on click of command button MS CRM 2015 – Step by Step


In this blog we will provide step by step process to call your java script function from command button. We are using RibbonWorkbench editor to create command button. You can download RibbonWorkbench tool from here and import it your crm organization by navigating Settings->Solutions->Import. Let’s first add our demo java script function, use following steps:
  • Create a solution by navigating Settings->Solutions->New and using following settings
    • Name: Demo
    • Publisher: Select default publisher of your organization
    • Version: provide version number for example 1.0
    • Click Save
  • Select Web Resources from left components tree and click on New
  • Fill name and display name for your web resource and select Script (Jscript) under Type drop down
  • Click on Text Editor button and add hello function like below
function Hello() {   alert(“This is custom button”); }
  • Click on Ok button and Save and Publish your web resource
Let’s say we want to add custom command button on account form, so let’s add account entity to our solution, follow below steps to add account entity to your solution
  • Select Entities and click on Add Existing button
  • Select Account entity from list and click on Ok
  • Select “No, do not include Required Components” under Missing Required Components dialog and click Ok
Now we need to open RibbonWorkBench tool to use our custom solution. Follow below steps
  • Open RibbonWorkBench solution and select our Demo solution
  • Drag a button and leave it next to Save button under Form section like belowDragbuttonExpend button under Solution Elements and setup properties from right hand section like belowsetpropertyRight click on Commands tree and select Add New
  • Click on Actions lookup and click on Add button
  • Select Javasript Funciton Action and click on Ok
  • Use our Hello function and select our javascript web resource under library lookup and click on OK
  • Select our button again and associate command it with it like below
showdialog
  • Click on Publish button to publish all the changes.
  • Create new account record or open existing account, you should get your custom button and on click on this button we should get alert
alert

Monday, 7 January 2019

Best Practices in Dynamics CRM

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/best-practices-sdk

Sunday, 6 January 2019

Error ID3242: The security token could not be authenticated or authorized when connecting Scribe to Microsoft Dynamics CRM

Are you trying to connect to Microsoft Dynamics CRM from Scribe Insight and getting the error message “ID3242: The security token could not be authenticated or authorized”?
Error ID3242- Connecting Scribe to Dynamics CRM 1
I recently had this issue at a client and we spent some time trying to resolve it based on many other posts, most of which referred to Active Directory Federation Services (ADFS) configuration, audience permission settings and other suggestions. In our case, none of these things seemed to be the problem. Our connections were working fine a few days earlier and so we looked at what had changed. Turned out the certificates were about to expire and some work was happening related to that as well as an ADFS upgrade taking place. Previously, our connection to Dynamics CRM was defined with a domain level login like below:
Error ID3242- Connecting Scribe to Dynamics CRM 2
This was working fine but suddenly it failed with the ID3242 error message. My account was fine and I could still access Dynamics CRM through the browser just fine but Scribe would not connect for anyone. To resolve the issue it was a very simple change. It seems that with the upgrade of ADFS it now required the UPN (user principal name / MSDN – User Name Formats) login in order to authenticate. That is simply going from the domain login to the email address like this:
Error ID3242- Connecting Scribe to Dynamics CRM 3
Another option that worked was to use the Down-Level logon name (Domain\username)
Error ID3242- Connecting Scribe to Dynamics CRM 4
If you receive this error while trying to connect Scribe or anything else that consumes the Dynamics CRM services, give these suggestions a try and maybe you’ll be back up and running a little quicker. I hope this helps!
Did you know? Microsoft Dynamics CRM 2016 has been released! Check out the latest Release Preview Guide for all the latest features, and view the Dynamics CRM Roadmap at Microsoft’s new site http://crmroadmap.dynamics.com or read our blogs on Microsoft Dynamics CRM 2016 release. If you are looking for support for Microsoft Dynamics CRM, RSM offers a full range of services from implementation and optimization to development and support. We can also help install updates or make configuration changes. Contact our professionals for more information on our services at 855.437.7202 or via email at crm@rsmus.com.
If you like these insights, subscribe to our Dynamics Community News publication.

Friday, 4 January 2019

Web API and Organisational data service in Dynamics 365

Web API : supported in Dynamics 365

The Web API was introduced with Dynamics 365 for Customer Engagement. It provides a RESTful web service with full compatibility with the organization service. It uses JSON in the body of the HTTP requests and responses, which makes it very suitable for use with JavaScript. 




Organization Data Service : will be deprecated in future release of CRM

Also known as the “OData endpoint” or “REST endpoint for web resources.”

 The organization data service remains available and you can use it so that code written for earlier versions will continue to work.




Organization service

Also known as the “Modern app SOAP endpoint” and the “SOAP endpoint for web resources.”


The organization service can be used but it is much more complex than the Web API with JavaScript because the HTTP requests and responses are sent using XML, which must conform to specific schema and namespaces. 

Power Apps Drag & Drop Kanban code sample

  Introduction: The Kanban Board App Developers at a software company use the Kanban board to show their progress on development tasks and b...