Sunday, 22 May 2011

Managed Solution in CRM 2011- An Experiment with Managed Solution Part II

Related Post : http://crmdm.blogspot.com/2011/05/managed-solution-in-crm-2011-experiment.html

As you all know, the new concept called 'Solution' which bundles the components was introduced in CRM 2011. Lets try import / export of managed solution and see what happens to the entity.
Consider the following scenario.
So we have created 2 Organizations. First one is named as DEVELOPMENT and second one as PRODUCTION.
We have a solution called AP_Project1 which contains a custom entity called 'Map'. Inside the entity we have defined 2 new fields called ap_route and ap_stability.


Please note the 'Managed Properties' button. When we click on it we would get the following Webdialog.


By default it would be set as true. So let's change the value to false as shown and see how it would behave in PRODUCTION.

So lets export the AP_PROJECT1 as 'managed' solution.


Now we need to navigate to PRODUCTION and import this solution. Following are steps of import.




Now if we open the solution we could see that we can not directly edit any of the components of this managed solution. Well you could see that CRM displays this information more clearly as shown below.



Now lets navigate to Customizations.


So we could see that the our custom entity is listed in Default Solution as shown below.


Please note the New and Delete button is not available in this case.



Its NOT possible to customize this entity because before importing the solution we set the managed properties as False. Please refer 4th screen shot of this post.

Now lets delete the managed solution from PRODUCTION.


So it clearly says that CRM would delete all the components of the managed solution. In order to verify lets delete the managed solution.

Now lets verify whether our custom entity is removed from Default solution.


As you could see the custom entity 'Map' is removed from Default solution.















Saturday, 21 May 2011

Managed Solution in CRM 2011- An Experiment with Managed Solution Part I

Related Post : http://crmdm.blogspot.com/2011/05/managed-solution-in-crm-2011-experiment_22.html

As you all know, the new concept called 'Solution' which bundles the components was introduced in CRM 2011. Lets try import / export of managed solution and see what happens to the entity.
Consider the following scenario.
So we have created 2 Organizations. First one is named as DEVELOPMENT and second one as PRODUCTION.
We have a solution called AP_Project1 which contains a custom entity called 'Map'


Please note the 'Managed Properties' button. When we click on it we would get the following Webdialog.


By default it would be set as true. So let's keep the value as true and see how it would behave in PRODUCTION.

So lets export the AP_PROJECT1 as 'managed' solution.


Now we need to navigate to PRODUCTION and import this solution. Following are steps of import.




Now if we open the solution we could see that we can not directly edit any of the components of this managed solution. Well you could see that CRM displays this information more clearly as shown below.



Now lets navigate to Customizations.


So we could see that the our custom entity is listed in Default Solution as shown below.


Its possible to customize this entity because before importing the solution we set the managed properties as True. Please refer 3rd screen shot of this post.

Now lets delete the managed solution from PRODUCTION.


So it clearly says that CRM would delete all the components of the managed solution. In order to verify lets delete the managed solution.

Now lets verify whether our custom entity is removed from Default solution.


As you could see the custom entity 'Map' is removed from Default solution.















Tuesday, 17 May 2011

How to get the logical name of the entity for the current record in CRM 2011 using Javascript

Code Snippet:  var entityName = Xrm.Page.data.entity.getEntityName();
 
 For instance , if the current record is contact the above code will return a string "contact"

Sunday, 15 May 2011

How to set focus on a control in CRM 2011 using Javascript

How to set focus on a control in CRM 2011 using Javascript
 
Code Snippet: Event: Form Load
 
var control = Xrm.Page.ui.controls.get("AttributeName");

control.setFocus();

Friday, 13 May 2011

Lookup Filtering in CRM 2011 using Javscript OR Custom Lookup Filtering in CRM 2011 using Javascript

Related Post : http://crmdm.blogspot.com/2011/04/lookup-fitering-feature-in-crm-2011-or.html

Let's see how we could configure custom lookup filter in CRM. Consider the following scenario.
We have a field called General Practitioner on the Account entity. We would like to place this field as a lookup of contacts. But the lookup of contacts should be filtered based on the profession field of Contact entity. So the lookup would be a list of doctors whose profession='Doctor'.

The contact records without filtering:


Also the contact form is shown below.




The main steps for the lookup filtering are the following.

Step 1: Build FetchXML
Step 2: Build Grid Layout
Step 3: Attach the new view to the lookup
So lets do it.

Step 1: Build FetchXML
As the first step of filtering we need to have fetchxml. But we don't need to worry about creation of FetchXML. MS Dynamics CRM will do it for you. But we need to decide 2 things
1) View of the Lookup
2) Filtering criteria
So navigate to Advanced Find and search for the contact records whose profession = 'Doctor'
Then you would get the following result.


We have defined a custom view with limited number of fields as shown below.


If we go back to Advanced Find tab, we could see a button called Download Fetch XML


Download the fetchXML to any local folder. The fetch XML file is shown below.


Step 2 & 3 should done in directly in the Js file. So we should call js function at the form load of Account. For your convenience, I have pasted the contents of the js file with proper comments.

Note: Do not forget to reformat the contents of FetchXML file as shown in the code below.
Step2 is the process of building a layout for the Lookup which is commented in the code (Its always ideal to keep same fields in the view used with the fetchXML and lookup View(except Id field). Remember the step Decide view while doing fetchXML). Also the step3 which is attaching the filterd lookup view to the lookup field General Practitioner is commented in the code.

function FilteredLookup() {
//Filter Condition--> Show Contacts which has got a Profession value as 'Doctor'
//Part 1 -->build fetchxml
var viewId = "{a76b2c46-c28e-4e5e-9ddf-951b71202c9d}"; //Any Guid is fine.
var entityName = "contact";// Entity to be filtered
var viewDisplayName = "Doctors"; // Custom name for the lookup window.
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='contact'>" +
"<attribute name='fullname' />"+
"<attribute name='contactid' />"+
"<attribute name='salutation' />"+
"<attribute name='new_profession' />"+
"<order attribute='fullname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='new_profession' operator='eq' value='100000001' />"+
"</filter>"+
"</entity>"+
"</fetch>";
// Part 2 --> Build Grid Layout. In other words, building a custom view for the Lookup
//building grid layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='name' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"<row name='result' " +
"id='contactid'>" + // Id attribute of the entity to be filtered
"<cell name='salutation' " + //Column1 - Salutation
"width='300' />" +
"<cell name='fullname' " + //Column 2 - Fullname
"width='100' />" +
"<cell name='new_profession' " + //Column 3 - Profession
"width='100' />" +
"</row>" +
"</grid>";
 

 
//Part3 add new view to the lookup
Xrm.Page.getControl("new_generalpractitioner").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
 

}


So here we go. As you could see only Doctors are listed in the lookup. The important point is that you could appy any filtering in the form of FetchXML. So I would say fetchXML is a cool feature in MS Dynamics CRM.