Wednesday, February 22, 2012

How to debug XAML bindings in Silverlight 5

Microsoft has released Silverlight 5 !! A new feature is available in Silverlight 5 and it is XAML Data Binding debugging. For any data driven application with declarative data binding, within XAML, this brand new feature is the significant in various ways.

Prerequisites:


Silverlight 5 toolkit
Silverlight 5 Developer Runtime
Visual Studio 2010 SP1

The example demonstrated here implements basic XAML data binding. Below we have specified both the scenario when binding is correct and incorrect.

In below example we have given a simple binding for DataGrid.

When Binding is Correct:




Now you can apply a breakpoint to the binding syntax. Once the break point is applied, it hits the breakpoint whenever push and pull is triggered for that control. The below image shows the breakpoint applied within XAML


The XAML editor will not allow you to set breakpoint anywhere else other than Binding syntax.
Once Breakpoint is set, start debugging and wait for the compiler to hit the breakpoint.


You can find the debug information from Local tab.


The information shows up a BindingState object holding complete binding context information of the control. As in the above image, the BindingState value is UpdatingTarget so this way it shows that the binding is pushing data to control.

Going through the debugging information, it shows the complete picture on the nature of data and binding


Now another thing to know is, on TwoWay binding scenario once you change the data, The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status. The breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status.


When Binding is Incorrect:

When binding is incorrect you will get the error while debugging the binding.


This will help you to find the incorrect bindings in your XAML.
Hope this helps you to get acquainted with the new feature of Silverlight 5

Wednesday, February 8, 2012

Features to be included in the Q2 2012 service update.

Some very exciting features have been announced that would be made available in the Q2 2012 service update. Here we discuss a few of them

Cross Browser Support
CRM had been restricted till date to be accessible through Internet Explorer only. However, with this release the user would now have the choice of browser. They can choose from IE v7+, Firefox v6+ and Chrome v13+. Safari v5.1.1+ as a browser would be supported on Apple Mac OS-X and iOS 5.x.

CRM Anywhere:
Besides giving a choice of browser, it will also provide mobile options as a part of the new cloud based mobile CRM service called Microsoft Dynamics CRM Mobile. This would however be a paid service and to begin with only be available in 24 markets (India not included) Native apps would be available for the following devices

Windows Phone v7.5+
Apple iPhone 3GS+ iOS 5+
Google Android v2.2+
RIM Blackberry v6.x +
Apple iPad/iPad2 iOS 5+

Note: The initial release of Microsoft Dynamics CRM Mobile for Windows Phone will not support offline data

Dashboard view would also be available on the mobile. Check this out…



Industry Solution Templates:
Industry templates would be made available for the following

Life Annuity Insurance Sales
Non-Profit
Health Plan Sales
Wealth Management

Custom Workflow Activities in CRM Online:
It was not possible to create custom workflow activities in CRM Online and solutions had to be re-designed around Plugins most times. It would now finally be possible to create Custom Workflow Activities in CRM Online as well.

Rapid View Forms:
It would now be possible to design Rapid View Forms that would be read-only forms. This would help the forms to be loaded quicker when the purpose of accessing the data is only to read the information and not make any edits. It would be possible to convert the read-only form to edit mode at the click of a button.

It would be possible for the user to decide if they wanted their forms to be loaded by default in the read-only mode or edit mode.

To read in detail about the features to be introduced check out the
release preview guide

Sunday, February 5, 2012

Maplytics now available for CRM 2011


We are happy to announce the availability for Maplytics for CRM 2011. The new version now supports all 3 CRM deployment models On-Premise, Online as well as IFD.

Maplytics is geo-analysis tool that allows you to view your CRM data on a map as well as allow your Sales Rep on the field to plan their schedule with the aid of Maplytics.


This new release supports Street View. Street View allows you to get a road side view of the address


You can also select multiple addresses and have the tool plot the route through the addresses selected.


Ability to Print the map as well as the route directions so that it can be circulated within the team.


It can now be added as a Dashboard component in your Dashboard.

Click here for more details.

Wednesday, February 1, 2012

Pass Custom Parameters to an entity form through a URL

In your applications, you may want to pass custom query string parameters to an entity form.
Let me describe the way in which we can define a set of specific parameter names and data types that can be accepted for a specific entity form.

Define Allowed Query String Parameters:
There are two ways to specify which query string parameters will be accepted by the form:
• Edit form properties
• Edit form XML

Edit Form Properties:
When you edit an entity form, on the Home tab in the Form group, click Form Properties. In the Form Properties dialog box, select the Parameters tab. Use this tab to modify the names and data types that the form allows as given in the below screen shot.


The following describes the querystringparameter element attributes, name and type:Name: Each name attribute must contain at least one underscore ('_') character, but the name of the query string parameter cannot begin with an underscore. The name also cannot start with 'crm_'. We strongly recommend that you use the customization prefix of the solution publisher as the naming convention. If you don’t follow the naming conventions the alert message as given in the below screen shot will be shown to the user.


Type: Following types of parameters can be passed to the form. Match the data type values with the parameter values so that invalid data is not passed with the parameter. The following are valid data types:
• Boolean
• DateTime
• Double
• EntityType
• Integer
• Long
• PositiveInteger
• SafeString
• UniqueId
• UnsignedInt

Let me define the parameters for the form and access them through Query string parameters.

- We have created two parameters for the Account Form as given in the below screen shot.


- We have opened the form through the below given script with parameters appended to the URL.
var extraqs = "Parameter_Source=Hello";
extraqs += "parameter_Source2=8";
//Set features for how the window will appear.
var features = "location=no,menubar=no,status=no,toolbar=no";
// Open the window.
window.open(Xrm.Page.context.getServerUrl() +"/main.aspx?etn=account&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs), "_blank", features, false);

- After that we have checked it through the query string parameters.
// Get the Query String Parametrs passedthrough the URL
var param=context.getQueryStringParameters();
// Get the Value of the Source through the Key Parameter Name
var source=param["Parameter_Source"];
var source2=param["parameter_Source2"];
// if Source is Undefined i.e. the URL Doesn't contain the key
if (source==undefined){ return; }
else{ // Perform the operation
}

This will be helpful in the scenario suppose if are opening the Form through the different sources such as Silverlight, report etc. and on the form load you want to perform some operation based on the source then you can define parameter for the form and can pass the source name in the extraqs of the URL as mentioned above and can check the source name on the form load and can perform the operation accordingly.

Monday, January 23, 2012

Update the Parent Silverlight Grid from the CRM form that is spawns.

We were working on the Silverlight REST Editor sample that is available in SDK.


We added a hyperlink to that grid that would open the CRM Contact form for the selected contact. This would allow users to check in further details of the contact. The users can also update the fields on the contact form there. Say the user edits the Phone on the Contact form instead of in the editable grid that we have presented them with… (users always tend to do what they are not supposed to do )

Now the issue raised was… after closing the CRM contact form, the changes made on the contact were not reflected in the grid. The user did not want to perform the search again to check the updated values…

How do we fix this…

1. Modify the Silverlight controls class and qualify it with the [ScriptableType] attribute.

[ScriptableType]
public partial class MainPage : UserControl
{

public MainPage( )
{
InitializeComponent( );

HtmlPage.RegisterScriptableObject("MainPage", this);

}

Register the control for access through script.

2. Next create qualify a method to be [ScriptableMember]

[ScriptableMember]
public void RefreshContactGrid( )
{
//Here write the code to rebind the Grid
}

Now we can access this method through jscript.

3. In the HTML page add a function to call the RefreshContractGrid method

function reloadContactGrid( ) {

try {
var control = document.getElementById("silverlightControl");
control.Content.MainPage.RefreshContactGrid( );
}
catch (e) {
alert(e.Description );
}
}

Silverlightcontrol refers to the object id of the silverlight control on the HTML page.
<object id="silverlightControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

And “MainPageis the class name, which we have registered as Scriptable Object.

4. As we would like the grid to be auto-refreshed on the close of the CRM form. We need to write the code on the CRM form OnSave event to call the reloadContactGrid function of the HTML page. This function internally calls the Silverlight method that actually binds the grid once again and refreshes the datagrid.

function reloadParentGrid( ) {
try {

if (window.parent != null
&& window.parent.opener != null
&& window.parent.opener.document != null
&& window.parent.opener.document.nameProp != null
&& window.parent.opener.document.nameProp == "RESTContactEditor") {

window.parent.opener.reloadContactGrid( );

} //End of IF

} catch (e) { }
}

With these 4 steps you should be able to auto-refresh the grid after the user saves the CRM form that they opened from within the grid.