locked
Copy notes from Lead when qualifying as Account RRS feed

  • Question

  • I followed this tutorial, but get the following error when viewing an account record:

    And below is the script as it is in my web resources:

    function CopyAttachment(context){
    var lookupItem = new Array;
    lookupItem = Xrm.Page.getAttribute('originatingleadid').getValue();
    var IFRAME_LeadNotes=Xrm.Page.getControl('IFRAME_LeadNotes');
    var src='';
    
    if (lookupItem != null)
    {                
                    src="/"+context.getContext().getOrgUniqueName()+"/_controls/notes/notesdata.aspx?id="+lookupItem[0].id+"&ParentEntity=3&EnableInlineEdit=false&EnableInsert=false";
    }
    else
    {
                    src="about:blank";
    }
                    IFRAME_LeadNotes.setSrc(src);
    }
    I named everything exactly the same as the tutorial.


    • Edited by nasyrax Tuesday, August 19, 2014 8:58 PM
    Tuesday, August 19, 2014 8:54 PM

Answers

  • So there is a relationship between Account and Lead, called Originating Lead.  If you don't actually have that field populated, there is no way to actually get the Notes froma Lead, because which lead do you get it from? CRM has to know that. 

    The line:

    lookupItem = Xrm.Page.getAttribute('originatingleadid').getValue();

    is where it looks at the relationship of originatingleadid and gets what the source lead is. Also, there appears to be a bug in the code where it doesn't catch the "null" value properly, even though the "else" statement is supposed to give you just a blank iFrame if there is no originating Lead.

    So you have two steps to take:

    1. Make sure you have the Originating Lead field filled out on an Account when appropriate.  Not all Accounts will start from a Lead.

    2. Since not all Accounts start from a Lead, find a way to fix the JavaScript to handle a null value when there is no originating Lead.


    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    • Marked as answer by nasyrax Wednesday, August 20, 2014 4:01 PM
    Wednesday, August 20, 2014 3:19 PM

All replies

  • Does that Account actually have an Originating Lead on it?

    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    Tuesday, August 19, 2014 9:23 PM
  • What exactly do you mean? Still a bit of a n00b. I created the iframe and web resource, applied it to the Account form, created a new lead with some notes, then qualified the lead to an account, but nothing happens but the error when I open an account record. Also, I'm using CRM 2011.
    Wednesday, August 20, 2014 12:03 PM
  • you need create a plugin on qualify of lead you need to get all notes attach to that lead and create notes again in account record.

    i dnt think so it will work with url

     

    ms crm

    Wednesday, August 20, 2014 12:25 PM
  • So there is a relationship between Account and Lead, called Originating Lead.  If you don't actually have that field populated, there is no way to actually get the Notes froma Lead, because which lead do you get it from? CRM has to know that. 

    The line:

    lookupItem = Xrm.Page.getAttribute('originatingleadid').getValue();

    is where it looks at the relationship of originatingleadid and gets what the source lead is. Also, there appears to be a bug in the code where it doesn't catch the "null" value properly, even though the "else" statement is supposed to give you just a blank iFrame if there is no originating Lead.

    So you have two steps to take:

    1. Make sure you have the Originating Lead field filled out on an Account when appropriate.  Not all Accounts will start from a Lead.

    2. Since not all Accounts start from a Lead, find a way to fix the JavaScript to handle a null value when there is no originating Lead.


    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    • Marked as answer by nasyrax Wednesday, August 20, 2014 4:01 PM
    Wednesday, August 20, 2014 3:19 PM
  • Gotcha! And again, I had a field missing from the form, Originating Lead wasn't there. As soon as I added it, it worked. Thanks SOOOOO mush for all your help Wayne! You have been an indispensable source of information!! I will do some research about the null value and see what I can find.
    • Edited by nasyrax Wednesday, August 20, 2014 4:02 PM
    Wednesday, August 20, 2014 4:01 PM
  • You're quite welcome!

    And take a look for Try/Catch statements.  Something like the code below around setting the lookup item.  That's almost certainly not functional as written (I haven't tested it at all), but should give you some direction for handling Accounts without Lead Sources.

    try {
    lookupItem = Xrm.Page.getAttribute('originatingleadid').getValue();
    }
    catch(exception)
    {
    lookupItem = Null;
    }
    
    


    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    Wednesday, August 20, 2014 4:45 PM