Thursday, December 26, 2013

Printing Entity Images on Reports in Dynamics CRM 2013


In our earlier post Now Store Images in CRM 2013 we discussed at length about the new Image attribute added to CRM 2013. It included steps to programmatically read/write to this field. The next step being the ability to include the image attribute in the reports.

This seemingly appears a simple task to include images just as the images were picked up earlier from the notes entity and displayed on the report. But when we tried to do the same with the image attribute, we found that the image attribute is actually not stored the same way as the attachments.

We could use the following code to read the image data using the CRM SDK

string binaryImageQuery =
                "<fetch mapping='logical'>
                <entity name='lead'>
                <attribute name='fullname' />
                <attribute name='entityimage' />
                </entity>
                </fetch>"

EntityCollection binaryImageResults = _serviceProxy.RetrieveMultiple(new FetchExpression(binaryImageQuery));

This would return the image data in binary format that we could then read in a byte array.

But when you execute the same fetch query using BIDS for report designing, you receive the following results

 
This appears all good but when you set the control source of the image control on the form to the entityimage attribute, it returns an error about the data in the field not being in correct format.

Upon further review of the results we found that the System.Byte[] did not mean the binary data but only the string “System.Byte[]”.

The Fetch query when executed using the RetrieveMultipe API as shown above returns binary data. But when the same query is executed using the ExecuteFetch API call, the results are returned in xml format and therefore the image attribute returns only a string “System.Byte[]” not the actual image binary data in Base64 string.

ExecuteFetchRequest fetch = new ExecuteFetchRequest();

fetch.FetchXml = binaryImageQuery;

_service.Execute(fetch);

As a result of this, reports designed using FetchXML (reports in CRM Online) would not be able to include images on the report.

On-Premise installs can still add the images in the report using SQL queries.

select con.FullName, con.Parentcustomeridname,con.entityimage  from FilteredContact con

Bind the image control in the report to entityimage attribute

The result would be

Hope this helps anyone trying to include images on reports.

Thursday, December 12, 2013

Pass Custom Parameters to an entity form through a URL in CRM 2013


This blog posted back in 2012, described how to pass custom parameters to an entity in CRM 2011. The other day tried to use the same code to make it in CRM 2013 but unfortunately that would not work. You will be able to pass a single parameter through the URL using the same code as before, but to pass more than one parameters, you need to use the new openEntityForm client API.

In 2011, the parameters would be concatenated to make a string and pass that as the extraqs query string

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);


Using the new client API to open the record, this would now be presented as follows

var parameters = {};

parameters["myparam_test"] = "1";

parameters["parameter_test"] = "100";

//use the openEntityForm to open the record

Xrm.Utility.openEntityForm("account", null, parameters);

Tuesday, December 10, 2013

Mobile Client for Dynamics CRM 2013


Mobile app for Dynamics CRM is out for Android, iOS and Windows Phone platform. When you navigate to CRM in your web browser on a blackberry device you are redirected to the mobile version as well. So true to BYOD, Dynamics CRM is now available through Web clients, Outlook Clients, Tablet Clients and Mobile clients as well J

You can download the mobile apps on different platforms through their respective app stores.

When you start the app, you will be required to enter the credentials to sign in.

 
 
Note: Unlike the tablet client the mobile client allows you to sign out and sign in to another org without having to uninstall/re-install, since it only requires the credentials and not the org url to login.
Home Page
 
On an OOB CRM Org, you will find the following entities listed in the mobile app.
 


Entity configuration for mobile access

On the entity settings, check the CRM for phones option to make the entity available for access through mobile clients.


Rich Client

The mobile client unlike the earlier mobile express option provides a richer client and user experience in line with its tablet client. Though it does not provide for process driven forms, it still allows you to check on related records.

This is how an account form would look like on a mobile client


Related entities


 
Support for Click to Call and Click to Mail support.

 

You can click on a phone number field to directly dial the number on the mobile.

 

 
This however does not create a phone call record in CRM.
 
Similarly click on an email address to pop-up the email client prompt for composing an email.
 
 
The email again is not tracked in CRM.
 
Complete Task
You can check off your to-do list in CRM from your mobile by selecting the task and marking it complete
 
Support for lookup selection
You can now perform a lookup search similar to the webclient to select the appropriate record.
 
Customize Mobile form layout/design
Once you have enabled an entity for mobile access, you need to configure the mobile form for the entity. The tablet client used the same form as the web client and only rendered it differently. However the mobile forms are rendered off the mobile forms designed for the entity.
 

You can even add a field on the form for read-only access by clicking on the Read Only button.

Note: When the form is rendered fields that do not have any data assigned to them are not displayed on the form in View mode. When you click Edit button, all fields are displayed.

Mobile forms also support Role-based access. Assign the roles that need to have access to a particular mobile form.


 
This also means you can design multiple mobile forms per entity and provide role based access to each of them.

 

Use the Form Order setting to decide on the order in which forms are displayed
 
 
 
Conclusion
The new mobile client that only provides support to CRM organizations provisioned on the O365 platform and for On-Premise environment, IFD configuration is essential is a true rich client that matches the tablet client released earlier. This now brings CRM to your mobile and much more easily accessible and usable than before.