Archive for category CRM

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

Building Your Business Hub: Using the Power of Social for a More Productive Enterprise – CRM Connection – CRM Non-Technical Blogs – Microsoft Dynamics Community

Building Your Business Hub: Using the Power of Social for a More Productive Enterprise – CRM Connection – CRM Non-Technical Blogs – Microsoft Dynamics Community.

Major Service update released this morning! Especially love the cross- browser support being released Celendar year FY12!

Leave a comment

Re-Publish CRM Reports in SRS

Hi all,

Im back from my break and now 8 weeks into my new position as a CRM Manager with Deloitte Canada.

Today I came across some CRM 2011 challenges with Reports and having to re-publish my OOTB Reports to SRS.

This article is an ‘oldy’ but a goodie and still applies to CRM 2011. Use the application PublishReports.exe to re-post your Reports to Reporting Services Manager. See more here.

I hope to post more regularly as I learn more exciting tips and tricks with CRM 2011!

 

 

,

Leave a comment

CRM 2011: Plug-in Development so far…

Hello fellow CRM folks,

I apologise for my quietness these last few weeks, I have been heads down on a CRM 2011 upgrade and am now having to make some modifications to the plug-ins I built back in 2008 or so (CRM 4.0).

Interestingly I am finding the plug-in development to be fun, but challenging as I learn the new data types and tricks. The drivers license I had for CRM 4.0 certainly needs an upgrade as I come to terms with things like OptionSets now replacing picklists and Lookups becoming EntityReferences! I miss my named types!

On that topic I wanted to share a tidbit I found. Did you know the OptionSetValue type in CRM 2011 plug-ins does not return you the text value of the option?!?!? A tad frustrating that you can only return the ordinal, the rest is left up to a MetaData service query.

You can read more here on Ben Hosk’s blog.

I am expecting more quirks and tricks over the coming weeks as I get my head around the changes. I’ll try document as many as I can. Enjoy!

1 Comment

Registering Plugins on Many-to-Many relationships CRM 4.0

Im taking a step back in time today, back to 2009 and a problem that has arisen again for me today. Im trying to register a “Add” plugin event against a custom many-to-many relationship. Out of the box this isnt supported in CRM 4.0 (apparently it was omitted before release due to more testing needed).

There is a work around that has been out there for while from Aaron Elder I wanted to share.

Step 1) Backup up your CRM Database

Step 2) Run the following SQL script against your MSCRM database

-- ============================================================================
-- Enable Associate and Disassociate Plug-in Events Script v1.0
-- ----------------------------------------------------------------------------
-- (c) 2009 Aaron Elder
-- ============================================================================
-- DISCLAIMER:
-- This script is provided "AS IS" with no warranties, and confers no rights.
-- ============================================================================
-- While this is obviously "unsupported", I think the fact that these events
-- are not available is a bug and hopefully it will be fixed in a rollup.
-- ============================================================================

USE AscentiumCrmDev_MSCRM
GO

-- Find the deployments SDK Filter ID for the
-- Associate and Disassociate Entity SDK Messages
DECLARE @DisassociateEntitiesFilterId uniqueidentifier
DECLARE @AssociateEntitiesFilterId uniqueidentifier
SET @DisassociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'DisassociateEntities')
SET @AssociateEntitiesFilterId = (SELECT SdkMessageId FROM SdkMessageBase WHERE [Name] = 'AssociateEntities')

-- Enable the Associate and Disassociate Filters to be valid for custom processing
-- Custom Processing means "you register plug-ins against it"
-- Note: We only do this for the "generic" (OTC == 0) case, just to be safer
UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
       WHERE SdkMessageId = @DisassociateEntitiesFilterId AND PrimaryObjectTypeCode = 0

UPDATE SdkMessageFilterBase SET IsCustomProcessingStepAllowed = 1
       WHERE SdkMessageId = @AssociateEntitiesFilterId AND PrimaryObjectTypeCode = 0

Step 4) Recycle the CRMAppPool for CRM and open up your Plugin registration tool.

Step 5) Register a Step with the message “AssociateEntity” or “DisassociateEntity”. As expected the many-to-many bridge tables are not exposed in the entity list, so you just leave this blank.

Step 6) Now the obvious issue here is ALL many-to-many relationships in your CRM system will trigger off this plug-in as it cannot be entity specific. I did some digging and the easiest way to limit this to a single relationship is to check the Target input parameters. Typically you would be looking for entity name in the context – this does not exist for many-to-many. The next best thing is the relationship name which can be found here:

string relationshipName = context.InputParameters.Properties[“RelationshipName”];

Do a comparison to the name of your many-to-many relationship and proceed with your custom code if a  match is found.

From what I can see, CRM 2011 also supports the AssociateEntity and DisassociateEntity messages, so while this might be unsupported, atleast Microsoft have continuity in CRM 2011. I stress the code above is unsupported, use at your own risk.

, , , ,

Leave a comment

Where is the CRM 2011 Metadata browser?

People have been asking “Where is the metadata browser in Microsoft Dynamics CRM 2011?”. For those of you who don’t know what the original metadata browser was, see Metadata Browser. The original metadata browser was removed from CRM 2011.

I’m happy to announce that the latest update to the Microsoft Dynamics 2011 Software Development Kit (SDK) includes a managed solution that replaces and I hope improves upon the original metadata browser.

To read more check out Jim Daly’s blog over at Microsoft here.

, ,

Leave a comment

CRM 4.0 – Rollup 16 Released

A major CRM 4.0 rollup was released last week in the form of Rollup 16.

If you havent reviewed the fixes yet, visit the download site here.

,

Leave a comment