Thursday, December 18, 2008

Microsoft CRM 4.0 Viewing the Original Lead’s Notes in an Account

I’ve often been asked by my clients if it is possible to easily view the notes captured against a lead in the created account or contact after a lead is qualified. Unfortunately other than going back to the original lead there is no way to easily achieve this. However there are a few options available  to solve this  problem and these include:

  1. Develop a plug-in to copy notes from the originating lead to the created account or contact.
  2. Write a Reporting Services Report to show notes from the originating lead and allow the user to run the report from within the account or contact.
  3. Show the originating lead’s notes in an iFrame in the account or contact screen.

I have found #3 the easiest to implement and users generally like it as they don’t need to go outside of the account / contact form to see the originating lead’s notes.

To demonstrate how to achieve this I’ll use the account form in my example but you could just as easily achieve this in the contact or opportunity form. First we will need to customise the account form, adding a new tab and section called Originating Lead Notes and then adding an iFrame called IFRAME_LeadNotes. Set the URL of your iFrame to about:blank and untick Restrict cross-frame scripting. I also set my iFrame to automatically expand to use the available space.

image

Next add the following JavaScript code to your form onload event":

var lookupItem = new Array;
lookupItem = crmForm.originatingleadid.DataValue;

if (lookupItem != null)
{
crmForm.all.IFRAME_LeadNotes.src="/_controls/notes/notesdata.aspx?id="+  lookupItem[0].id +  "&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false";
}
else
{
crmForm.all.IFRAME_LeadNotes.src="about:blank";
}

Publish your changes and you are now able to view the original lead’s notes in your account form.
image
To make the solution even more user friendly rather than show a blank iFrame you may want hide the Lead Notes tab if there is no Originating Lead. This solution can also be used in other areas where you want to show notes from another record on a form. The skies are the limit :)

21 comments:

Unknown said...

Do you know if it would be different code for 3.0?

Karl Iuel said...

I have not had a chance to test this with CRM 3.0 but in theory yes the code should remain the same.

Unknown said...

Hmm...I tried testing it and nothing comes through for some reason. I thought maybe some of the paramters are different, etc? I'm not a coding person, so its all foreign to me. I just copy / paste. But its so frustrating they didnt build that function into CRM!

Karl Iuel said...

Unfortunately I don't have a version 3.0 of CRM to test this at the moment so I'd be very interested to see if the parameters have changed between versions. One way to quickly test if this will work with version 3.0 is to try see if the following url returns the notes screen. http://[name of your crm server + port]/_controls/notes/notesdata.aspx?id=[replace with the guid of the lead your wish to see the notes for]&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false.

Unknown said...

Thanks for the reply, strangely it still didnt work. Even though the lead form with that GUID has notes, the resulting screen from pasting that URL is completely blank. Very strange.

Karl Iuel said...

I have only tested this with version 4 so it must be that the either the parameters and or the url has changed between versions. I'll have to hunt down a version 3.0 VPC and see if I can find a solution for CRM 3.0. I'll post the solution here the moment I solve it :)

Karl Iuel said...

Ok finally managed to hunt down a version 3.0 VPC and have unfortunately found that this solution will not work with CRM 3.0. The notes.htc page expects to be embedded in a parent form and because of that you get a blank notes screen even though you pass in the object id.

To create a solution similar to this in CRM 3.0 you could write a SRS report and embed that in an iFrame to achieve a similar result. Bit more work though :)

Unknown said...

thank you, this prevents me from wasting any more time trying to figure this out. I thought other people posted it worked for them in 3.0.

I think I figured out the only solution is to hide notes field and force everyone to enter notes into the activity

Saravanan said...

Superb article easy way to achieve your requirement.

Unknown said...

When I run this I get the following message in the IFRAME window but only when my original lead has notes ... any ideas??

Invalid User Authorization
The user authentication passed to the platform is not valid.

Unknown said...

Sorry I worked it out ..... I have multiple organizations and I had to include the ORG name in the URL on JS code.

Zach Livingston said...

This worked like a charm in 4.0. Thanks so much!

Quercus said...

Nice post!
Had to add https://customer.crmhostcompany.com/ in front of ?= URL to get it to work on our hosting solution.

Do you have a script on how to hide this tab if empty?

Regards,
Henrik

Quercus said...

Karl Luel already talked about the URL :-)

Mike Karls said...

Karl, the code works but now my notes section is very small (only see 3 lines) and have to scroll down. Is there a way to just import these originating notes into the notes section or a way to make the notes section larger?

Dominic Lozano said...

Code works well. I can now view Account notes in the Contact Entity. Is there a way to also be able to add an Account level note from the contact record view. I changed the param EnableInsert=false to true but then get an error, record not found, when I try to create a new note. Any thoughts?

Karl Iuel said...

Hi Dominic,

Unfortunately this is a read only solution. You can set EnableInlineEdit=true&EnableInsert=true but this will end up adding the note to the contact not the parent account. I don't believe there is a simple way to allow notes to be added to the parent account from the contact

Anonymous said...

I used your process for my job's CRM4.0 online, but kept it in the same tab as the Account notes. We are making some updates, and I have moved the lead notes iframe to it's own tab however now the account notes does not expand to the whole page and I cannot figure out how to make this occur. I would really appreciate some guidance.

Karl Iuel said...

Hi Tim,

You need to set the Row Layout for the iFrame to automatically expand to use all free space. To do this go the iFrames properties (double click on the iframe in the form editor), select the formatting tab and then check the "Automatically expand to use available space" checkbox.

Hope this helps :)

Mike Karls said...

Has anyone done this in CRM 2011?

pearse said...

I have a similar problem. I scan the business card as lead. The image file of the card is stored under notes automatically when I save the record.Now When I later qualify to a contact this image is lost. I sthere a way I could somehow and somewhere save the image along with th econtact info.Thanks