deepakkumar5035

Working as a Microsoft Dynamics CRM Consultant at Microsoft.

Homepage: https://deepakexploring.wordpress.com

Data Encryption Error in CRM


Recently when we were trying to update the user’s email address in CRM 2015 On Premise version we were getting the below error and we were not able to update even though the user with  which we were updating was having System Administrator and Customizer Security Roles. We were getting the below error

“There are encrypted fields in the organization database, but the data encryption feature isn’t activated. Contact your Microsoft Dynamic CRM system administrator to activate data encryption. To activate, go to Settings > Data Management > Data Encryption. For more information, see http://go.microsoft.com/fwlink/?LinkId=316366.”

After analyzing the issue, we figured it out that the error is coming since this environment was newly set up by taking a DB Backup from another CRM instance where data encryption was activated. We updated with the same key from the CRM instance from where we took this backup.

How & Where to copy the Key?

  1. Sign in to Microsoft Dynamics CRM as a user with the system administrator security role.
  2. Go to Settings > Data Management > Data Encryption.
  3. In the Data Encryption dialog box, select Show Encryption Key, in the Current encryption key box select the encryption key, and copy it to the clipboard.

In case your CRM is not configured for HTTPS then follow the below link http://www.crmphilly.com/crm-2013-data-encryption/

Advertisements

, , , ,

Leave a comment

2013 in review


The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 22,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 8 sold-out performances for that many people to see it.

Click here to see the complete report.

Leave a comment

Programmatically updating stages/process for Business Process Flow in CRM 2013


New release of CRM 2013 allows creating Business Process flows for custom entity as well. It also allows creating multiple processes flows for the same entity.  Different set of users can have different flows based on the business requirement. Even in some scenario’s we may need to shift from one process flow to some other process flow which should be generally done dynamically based on certain conditions.

We can enable Business Process Flows setting during creating custom entity or even we can update this in settings after the entity is created.

EnableSetting

 

Once we enable this 2 fields gets created for this entity.

Attributes

So when we want to change the current process flow or the current stage we need to update these fields. Unfortunately CRM has not provided any UI to update these fields directly. So we can update this either through JavaScript/plugins using CRM API calls.

Let’s see how to get these values and update accordingly. In my sample I have a Business Process Flow called – “Business Process for Enquiry” with the following stages – “New, Contacted, Confirmed, Visa processed and Close”.

BPF

As highlighted above we can enable this flow for distinct/different set of security Roles.

I need to update the stage to CONFIRMED automatically once few fields are updated. To achieve this I wrote the below code in my Plugin.

// Get the Process Id based on the process name
 string procesName = "Business Process for Enquiry";
 var workflow = (from p in orgContext.WorkflowSet
 where p.Name == procesName && p.StateCode == Entities.WorkflowState.Activated
 select p).FirstOrDefault();
 
 if(workflow==null)
 {
 throw new InvalidPluginExecutionException(string.Format("Worflow not found with name {0}",procesName));
 }
 
 //Get the stage id based on the Stage Name
 string stageName = "CONFIRMED";
 var stage = (from p in orgContext.ProcessStageSet
 where p.StageName==stageName.ToUpper() && p.ProcessId.Id==workflow.WorkflowId
 select p).FirstOrDefault();
 if(stage ==null)
 {
 throw new InvalidPluginExecutionException(string.Format("Stage not found with name {0}", stageName));
 }
//Update the record with the new stage
 Entities.new_enquiry updateEnquiry = new Entities.new_enquiry();
 updateEnquiry.Id = context.PrimaryEntityId;
 updateEnquiry.stageid = stage.ProcessStageId;
 updateEnquiry.processid = workflow.WorkflowId;
 service.Update(updateEnquiry);

And that’s it. It does the job for me

FinalStageChanged

Happy Reading !!!!

 

 

, , , , ,

1 Comment

Actions in CRM 2013


One of the most powerful features introduced in CRM 2013 is Actions. It strongly supports the concept of XRM platform. Actions are the Custom messages which can be created for any entity or globally to perform business operations like create/update/Assign etc. (more than what a Workflow can do). Looking first time we get a feeling that it is very similar to Workflow but hold on it’s very different from WF’s or Plugins.

Below are the key points which make it different:
  1. Can be associated with single entity or globally.
  2. Actions support Arguments – Input and Output Arguments.
  3. Can be only called through web service calls – either JavaScript/Plugins/Web through API calls.
  4. Supports Rollback and executes in real time.
  5. Always runs under the context of the calling user.

Arguments

Arguments are the parameters or the variables which can be used while creating the action. There are two kinds of arguments

 Input Arguments:

These are the parameters which need to be passed during action call. These can be Optional/Mandatory. For Mandatory argument it is necessary to provide some value while calling this action. These input arguments can be used as variables while performing any operation in the action.

Output Arguments:

These are the parameters which can be returned when the action is called. These can be Optional/Mandatory.

To understand in an easy way we can compare actions with a Function/method in normal C# programming which can have parameters and also can return something at the end.

Let’s take a look of the different types of Arguments it supports.

ReturnTypes

Example:

Let me create a simple Action on Enquiry entity which has one Input Argument: ProjectName [string]

To create this we need to navigate to Processes and select Category as Actions. In primary entity I am selecting Enquiry which is custom entity in my case. I have taken one Input Parameter- ProjectName. And in the step I am using this Variable during creating a Project’s record which is again a custom entity.

CreatingAction

And here is the snap of the Step which I have configured. Here we can see that I am using this ProjectName as a dynamic value during the Project Creation. Here note that new_EnquiryCreateProject is the name of the Action which should be referred while calling this through API.

CreateProjectThroughAction

Let’s activate this Action and see how we can call this from Plugin or JavaScript.

Calling Actions from Plugins

Now we can call this Action from our Plugin. I have a Plugin which fires on Post Create of Enquiry. There I am calling this Action. I am passing the Input Argument ProjectName as Parameter before calling this Action. Once this is called It creates a new Project record.

// Calling the Action - new_EnquiryCreateProject
OrganizationRequest req = new OrganizationRequest("new_EnquiryCreateProject");
req["ProjectName"] = "This is a test operation for using Actions in CRM 2013 ";
req["Target"] = new EntityReference("new_enquiry", enquiryObj.Id);

//execute the request
OrganizationResponse response = service.Execute(req);

Calling Actions from Javascript

Yes we can call Actions through JavaScript. I have a stage field in the Enquiry entity and on Change of Stage field I want to call this Action. Let us see below how we can use this.

 function CallActionFromJavaScript() {
    var projectName = "Project Created through Action from Javascript";
    var entityId = Xrm.Page.data.entity.getId();
    var entityName = "new_enquiry";
    var requestName = "new_EnquiryCreateProject";
    ExecuteActionCreateProject(projectName, entityId, entityName, requestName);}
function ExecuteActionCreateProject(projectName, entityId, entityName, requestName) {
    // Creating the request XML for calling the Action
    var requestXML = ""
    requestXML += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
    requestXML += "  <s:Body>";
    requestXML += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
    requestXML += "      <request xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
    requestXML += "        <a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>Target</b:key>";
    requestXML += "            <b:value i:type=\"a:EntityReference\">";
    requestXML += "              <a:Id>" + entityId + "</a:Id>";
    requestXML += "              <a:LogicalName>" + entityName + "</a:LogicalName>";
    requestXML += "              <a:Name i:nil=\"true\" />";
    requestXML += "            </b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>ProjectName</b:key>";
    requestXML += "            <b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">" + project
Name + "</b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "        </a:Parameters>";
    requestXML += "        <a:RequestId i:nil=\"true\" />";
    requestXML += "        <a:RequestName>" + requestName + "</a:RequestName>";
    requestXML += "      </request>";
    requestXML += "    </Execute>";
    requestXML += "  </s:Body>";
    requestXML += "</s:Envelope>";
    var req = new XMLHttpRequest();
    req.open("POST", GetClientUrl(), false)
    req.setRequestHeader("Accept", "application/xml, text/xml, */*");
    req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationServic
/Execute");
    req.send(requestXML); 
    //Get the Resonse from the CRM Execute method
    //var response = req.responseXML.xml;
}
function GetClientUrl() {
    if (typeof Xrm.Page.context == "object") {
        clientUrl = Xrm.Page.context.getClientUrl();
    }
    var ServicePath = "/XRMServices/2011/Organization.svc/web";
    return clientUrl + ServicePath;
  }

And now the most Amazing part of Actions are that we can consider this as a unique message and can register this through Plugin registration tool and can do Custom Validations if we want to do during the execution time.

Let’s say during the execution of this Action I want to validate something or abort this Operation in certain conditions then we can easily do by registering this as a message which is  a great example of Xrm support in CRM 2013 as now it is not restricted to messages like Create, update, delete etc.

Below it is shown how we can register this through Plugin Registration Tool.

PluginMessage

Note: These actions are little bit different from Plugins as return type of the Target is not Entity but it is Entity Reference. During the execution of this Action we can get the Input Arguments and use this for any type of validations.

Below is the sample where I am reading the values of the Target and the Input Argument ProjectName used in the above example.

PluginSampleForAction

Here we can clearly see that the context contains only 2 values one is the Parameter and the other one is the Target.

As a developer, introduction to Actions in this CRM 2013 release is really a great improvement from CRM’s perspective which will help us to minimize the coding part and also achieve some complex requirement easily.

Happy Reading!!!!!

, , , , , , , , , ,

8 Comments

Creating Business Rules in CRM 2013


One of new feature added in new release of CRM 2013 is Business Rule. Though this is not very exciting feature provided by CRM 2013 but obviously this is something which developers can relish as it minimizes the burden of common JavaScript validation. Yes that’s true with the use of Business Rules we can easily perform few simple validation in the form without writing a single line of code.

Wow!!!! It sounds great… Let us have a quick walk through of this new feature and see how we can incorporate this for our requirements.

 Example:

When a lead source is changed to Partner – I want to make

1. Business Phone and Email as Mandatory Fields

2. Hide the Mobile Phone Field

Now let us create a Business Rule to meet the above requirement.  Business Rules comes as a part of your entity in the solution as shown below.

BusinessRulesAppear

Go to Business Rules for Lead entity and Create a new one. Here we can notice that we can do the following things

1. Add Conditions

2. Add Actions

3. Provide Description

In this example we have added one condition as if the lead source is Partner. In actions we can see that we are making the Business Phone as Mandatory, Hiding the Mobile Phone field and Making the email as Mandatory.

CreatingNewBusinessRules

There are very limited options available for the creating the actions like as shown below.

ActionsBusinessRules

Once we are done with the creation part we need to save this and activate. Similar to Processes we can activate and deactivate this Rules at any point of time. Also if we have multiple forms then we can also define for which forms these rules should be applied.

ScopeBusinessRules

One good I liked the most is that there is a Save As Option available so we can create multiple rules in minute and then edit accordingly.

Now we can see the desired result in the lead form(UI)LeadUI

Key points to be noted

1. If there is JavaScript written for same field then it executes before your custom business rules(Java script fires before Business Rules).

2.  It does not supports hiding/Showing  Tabs and Sections.

3.  This is similar to JavaScript so these rules do not trigger when any operation is performed by API calls.

4. Well supported in Mobiles and Ipad.

5. Rules can be applied form wise. So in case of multiple forms you may specify for which forms these rules is applicable for.

, , ,

Leave a comment

Error while publishing entity in CRM 2011


I was getting the below error while  publishing a particular entity as System Admin  in CRM 2011, though was not getting the error for other entities . The error was

The Requested record was not found or you do not have sufficient permissions to view it.”

The details of the error are :

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: role With Id = 3adccc07-6293-4cac-b790-4be053184063 Does Not ExistDetail:
<OrganizationServiceFault xmlns:i=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://schemas.microsoft.com/xrm/2011/Contracts”&gt;
<ErrorCode>-2147220969</ErrorCode>
<ErrorDetails xmlns:d2p1=”http://schemas.datacontract.org/2004/07/System.Collections.Generic&#8221; />
<Message>role With Id = 3adccc07-6293-4cac-b790-4be053184063 Does Not Exist</Message>
<Timestamp>2013-06-13T10:17:03.72479Z</Timestamp>
<InnerFault i:nil=”true” />
<TraceText i:nil=”true” />
</OrganizationServiceFault>

Resolution:

The below link helped me to solve the problem which was removing the extra form for this entity, I had 2 forms out of which one I was not using.

Though I do not fully agree on removing the extra form concept just to get rid of this problem,because this may not be the actual Problem but u know when something works for us we take it with both hands……

http://community.dynamics.com/crm/f/117/p/73740/135685.aspx#.Ubl_hflTDLM

 

 

 

,

Leave a comment

Exporting SSRS report to Word giving Error in CRM 2011


Recently in my Project I was getting a error for one of the report when I was trying to export to Word. Having not faced this issue before we started to hunt for the solutions. Then came to know that if the report is having more no of individual controls then while rendering that to word gives issues. To get rid of this you can group the controls in some other control(For Eg. Rectangle).

And here u go  …. your issue fixed ….

Below URL is a handy one  …

http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/14b0ff43-40b3-4132-9c63-b4731f62c48b

, ,

Leave a comment

2012 in Review


The WordPress.com stats helper prepared a 2012 annual report for this blog.
2012review

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 18,000 views in 2012. If each view were a film, this blog would power 4 Film Festivals.

Click here to see the complete report.

Leave a comment

By default all fields getting updated issue while using oData(REST) endpoint for Web Resources in Silverlight in CRM 2011


Recently I was facing a typical issue, while updating a couple of fields of a form using REST Endpoint in Silverlight, by default all the fields in the form was getting updated to null. I found this as very strange behavior by using REST in Silverlight.

In seek of answer I found that it was the default feature when you use REST Endpoint in Silverlight in CRM 2011.

The Below URL helped me lot which talks in very detailed manner the actual cause and Resolution.

http://blogs.msdn.com/b/crm/archive/2011/06/20/updating-records-using-the-rest-endpoint-for-web-resources-and-silverlight.aspx

Happy Reading …

, , , , ,

Leave a comment

Programmer’s …..


Just thought of sharing it …….

http://notgartner.wordpress.com/2006/02/19/the-day-programmer-vs-the-night-programmer/

,

Leave a comment