Wednesday, 5 October 2011

Originating Lead Notes in Accounts and Contacts

One of the nice features of Microsoft Dynamics CRM is the ability to qualify Leads to Accounts and Contacts, carrying through all that useful historical data including emails, activities etc. One of the things it doesn’t do is carry through the Notes from the Lead. Now you can easily get to it by navigating through the Originating Lead field, but it would be nice to see them there.

There are a few ways to achieve this including a report, but I think the best solution is to display the notes in an iFrame right in the notes section, perhaps being differentiated by calling them Original Lead Notes.

There were a couple of solutions for Microsoft Dynamics CRM 4.0, so I thought I would take some good points from these and tweak it for 2011.

Firstly you need to place an iFrame on the Contact or Account form (Or Both!) to display the Lead Notes. set it up with the following parameters, making sure that you note the Name, Set the URL to about:blank and un-tick the ‘Restrict cross-frame scripting’ box:

iFrame

You then need to setup the web resource that will hold the JavaScript.

The script is the following:

   1:  function OriginLead() 
   2:   {
   3:   var Primary = Xrm.Page.data.entity.attributes.get("originatingleadid");
   4:       var IFrame = Xrm.Page.ui.controls.get("IFRAME_LeadNotes");
   5:   
   6:      if (Primary.getValue() != null) {
   7:   
   8:          var GUIDvalue = Primary.getValue()[0].id;
   9:   
  10:          IFrame.setSrc("http://crmvm:5555/Contoso/_controls/notes/notesdata.aspx?id="+GUIDvalue+"&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false");
  11:          }
  12:       else 
  13:  {
  14:             IFrame.setSrc("about:blank");
  15:           }
  16:   
  17:   
  18:  }




You’ll notice a couple of things here..


Firstly the JavaScript is grabbing the GUID of the ‘OriginatingLead’ field. This is whats used in the URL of the iFrame set out in Line 10.


Also if there is no Originating Lead then the iFrame remains blank with no errors.


Once this is all done the results should be as follows:


Results


Enjoy


Rob

1 comments:

  1. Hey Rob
    Thank you for good article
    Though do you have the idea how to get other (custom) attributes

    ReplyDelete