Posts Tagged CRM Online

Adding a Profile Picture to a Contact Form – CRM 2011

I recently needed a good solution to add a picture to a CRM 2011 Online form and so I started searching around online for examples. There were not alot of clean and clear examples (or ones that didn’t involve the use of Silverlight!). I also wanted something that was Fetch based that I know would stand up against all these rollups coming down from Microsoft. It has always been reliable for me!

Below is a FetchXML version I created that works great and adds the picture to a Web Resource on the form; where the picture is stored as an associated Annotation. The only thing you need to do is name your Note “Profile Picture” when you go to attach your image. Where I reference ContactScriptLibrary I am calling the standard Fetch library that can found in the SDK .

I hope this helps someone else out there!

function setPictureUrl() {

// Contact ID
var entityId = Xrm.Page.data.entity.getId();

if (entityId) {
// Build Fetch query to retrieve the attached image with name “Profile Picture”
var query = “<fetch mapping=’logical’ count=’1′ version=’1.0′>”;
query += “<entity name=’annotation’>”;
query += “<attribute name=’annotationid’ />”;
query += “<attribute name=’documentbody’ />”;
query += “<attribute name=’mimetype’ />”;
query += “<attribute name=’subject’ />”;
query += “<filter type=’and’>”;
query += “<condition attribute=’objectid’ operator=’eq’ value='” + entityId + “‘ />”;
query += “<condition attribute=’isdocument’ operator=’eq’ value=’1′ />”;
query += “<condition attribute=’subject’ operator=’eq’ value=’Profile Picture’ />”;
query += “</filter>”;
query += “</entity>”;
query += “</fetch>”;

var xmlDoc = ContactScriptLibrary.Fetch(query);
var docBodyNode = xmlDoc.getElementsByTagName(‘documentbody’);
var mimeTypeNode = xmlDoc.getElementsByTagName(‘mimetype’);

// Check attachment body is available
if (docBodyNode != undefined && docBodyNode.length == 1 && docBodyNode[0].childNodes.length == 1) {
var documentBody = docBodyNode[0].childNodes[0].nodeValue;
}
// Check Mime type
if (mimeTypeNode != undefined && mimeTypeNode.length == 1 && mimeTypeNode[0].childNodes.length == 1) {
var mimeType = mimeTypeNode[0].childNodes[0].nodeValue;
}

// Populate the image in the Form web resource.
if (documentBody != null && mimeType != null) {
var fileContents = “data:” + mimeType + “;base64,” + documentBody
var img = document.getElementById(“WebResource_ContactImage”);
img.src = fileContents;
}
}
}

, ,

2 Comments

Error message when you try to import Microsoft Dynamics CRM Online customizations into a Microsoft Dynamics CRM 4.0 organization

I encountered an interesting scenario yesterday with a client where I needed to import their CRM 4.0 Online customizations into CRM 4.0 On-premise (Which was in a Virtual Machine). Perhaps this scenario isn’t overly common, but going forward if you have CRM 4.0 Online customers who want to go to say CRM 2011 On-Premise then there a few things you need to know.

I discovered there are several customizations that are only applicable to CRM 4.0 Online that will prevent the import being successful. After some further digging I found there is a tool available called the Migration Processer Tool which will allow you to “transform” your XML and prepare it for On-Premise.
When the MigrationProcessor Tool runs, it runs various processors configured in the Processor config file. The current version runs the following processors:

  • Visualizations Processor
  • Internet Marketing Processor
  • Helpvisor Processor
  • Homepage Processor

All processors, except the last processor have the IgnoreValidationErrors set to true as the work is not really complete and the validations do not succeed until the last processor succeeds in processing if all processors deal with different aspects of cleanup in the same element. In this case when the Internet Marketing processor completes its job it still has validation failures againt site map xsd as there is still cleanup work needed to be completed by the Help Visor processor and so you get the validation errors. Once the last processor set in the config file runs we do not expect any more validation errors as the set processors have all completed the job of cleaning up.

To access the Migration Processor tool, follow these steps:

  1. Download Update Rollup 7 for Microsoft Dynamics CRM 4.0. To do this, visit the following Microsoft Web site: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=a4893988-7804-4e23-ab58-740441cc696e (http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=a4893988-7804-4e23-ab58-740441cc696e)
  2. Save the downloaded file to a folder.
  3. Click Start, click Run, type cmd, and then click OK.
  4. Change directories to the folder that contains the file for Update Rollup 7 for Microsoft Dynamics CRM 4.0, type CRMv4.0-KB971782-i386-Server-ENU.exe /x, and then press the ENTER key.
    • I didn’t actually install Rollup 7, I just followed the steps in order to access and copy the tool. My CRM is patched with Rollup 12.
  5. Click Save when you are prompted to save the extracted files.
  6. Change directories to the Tools/Customizationmigrationprocessor directory. The directory is located where the extracted files were saved in step 5.
  7. At a command prompt, run the Migrationprocessortool.exe file that is located in the Customizationmigrationprocessor folder. To do this, run the following command:

migrationprocessortool Customizationfile
Notes

    • The Customizationfile placeholder represents the location of the Microsoft CRM Online customization file that you want to process.
    • When you run the Migrationprocessortool.exe file, the tool processes the customizations. Then, the tool saves a new file that is named “ProcessedCustomization.xml” in the Customizationmigrationprocessor folder.
    • The ProcessedCustomization.xml file contains a new set of customizations.

After you covert the CRM Online customization file into a CRM 4.0 customization file, use the ProcessedCustomization.xml file to import Microsoft Dynamics CRM Online customizations into a Microsoft Dynamics CRM 4.0 organization.

Done! I did notice that some of the Navigation items were not showing as they were in CRM Online, but after customizing My Workplace I was able to get everything back in place.

Please see the Microsoft Support KB http://support.microsoft.com/kb/976978 for more information.

, , , , ,

Leave a comment

CRM 2011 Developer and ISV Whitepaper

CRM MVP Julie Yack announces the release of her current whitepaper title:

Microsoft Dynamics® CRM 2011
Building Business Applications with Microsoft Dynamics CRM 2011
A guide to Independent Software Vendors and Developers

Some details you can learn about:

  • Modeling of your business data
  • A better user experience
  • Visualization and reporting of data
  • Programmability including OData, WCF, LINQ, Dialogs, Workflows and more
  • Cloud cloud cloud (CRM Online and Azure both covered)

Please visit Julies blog site here.

, , , , , , ,

Leave a comment