locked
Set Contact address from 'More Addresses' of Account RRS feed

  • Question

  • Suppose I have an Account with many addresses shown in More Addresses view (There is an address for New York, Chicago, etc).

     

    Now for this Account, I want to add a Contact. I would go into the Contacts view and click New Contact.

    However, for this new contact the address shown in the Details tab is empty, and I want to populate it from one of the addresses stored in the Account. For now we are just doing a copy/paste and it's quite tedious.

     

    Is there a better way?

     

    We're using CRM 4.0

     

    Thanks, Nehal

    Wednesday, August 27, 2008 6:34 PM

Answers

All replies

  • You can create an aspx page with an IFRAME that points to the parent (account) addresses associated view. And a button that drills into the crmGrid and copy the selected row. You also need to customize the view and add all the attributes you're interested in. finally you need to traverse the crmGrid columns names so you could reference the opener crmform and paste each column into its respective attribute. Does that make sense?

     

    Wednesday, August 27, 2008 7:44 PM
  • That makes sense. I was hoping there was an easier way (due to time constraints) but perhaps I will try your way out.

     

    Thanks.

    Wednesday, August 27, 2008 8:03 PM
  • Thought this would be a nice post / addition to my blog.

    I’ll add explanations about it in my blog later this week. 

     

    Add the “Lookup Address “ button to the isv.config.

     

    <Entity name="contact">

       <ToolBar ValidForCreate="0" ValidForUpdate="1">

          <Button Icon="/_imgs/ico_18_quota.gif"

                      JavaScript="

                       var account = crmForm.all.parentcustomerid;

                       if( account.DataValue != null )

                       {

                           var accountid = account.DataValue[0].id;

                           window.open('/' + ORG_UNIQUE_NAME + '/ISV/AccountAddressLookup.aspx?orgname=' + ORG_UNIQUE_NAME + '&accid=' + accountid + '&sec=' + crmFormSubmit.crmFormSubmitSecurity.value , '' , 'toolbars=0,width=700,height=500');

                       }

                       else

                       {

                           alert('you must select a parent customer first');

                       }" Client="Web">

                       <Titles>

                          <Title LCID="1033" Text="Lookup Address" />

                       </Titles>

                       <ToolTips>

                          <ToolTip LCID="1033" Text="Lookup Address" />

                       </ToolTips>

             </Button>

          <ToolBarSpacer />

      </ToolBar>

    </Entity>

     

    Add a new aspx page under the ISV folder called AccountAddressLookup.aspx with the following html.

     

    <%@ Page Language="C#" %>

    <html>

    <head>

    <title>Account Address Lookup</title>

    <script>

    var IFRAME_acclui;

    var IFRAME_accluiDoc;

     

    function OnAddressLookupReady()

    {

    IFRAME_acclui = document.all.IFRAME_acclui;

    if( IFRAME_acclui.readyState != 'complete' ) return;

    IFRAME_accluiDoc = IFRAME_acclui.contentWindow.document; IFRAME_accluiDoc.all._MBtopAddRelatedAddress1071.action = "top.opener.AddRelatedAddress(1071);"; IFRAME_accluiDoc.body.scroll = "no"; IFRAME_accluiDoc.body.childNodes[0].rows[0].cells[0].style.padding = "0";

    }

     

    function CopyAddress()

    {

    var crmGrid = IFRAME_accluiDoc.all.crmGrid;

    var columns = IFRAME_accluiDoc.all.gridBodyTable.childNodes[0].childNodes;

     

    for( var i = 0 ; i < columns.length ; i++ )

    {

    var column = columns[ i ];

    if( typeof(column.name) != "undefined" )

    {

    var attribute = opener.document.getElementById( "address1_" + column.name );

    if( attribute )

    {

    attribute.DataValue = crmGrid.InnerGrid.SelectedRecords[0][3].cells[ i ].innerText;

    }

    }

    }

    }

     

    </script>

     

    <style>

    .btn{border: 1px solid;}

    hr{color : #639ace;height:1px}

    body{background-color : #deebff;border:0px;}

    .header{font-size:20px;color : #6b92ce}

    </style>

    </head>

     

    <body scroll="no">

    <div class="header"> Account Address Lookup </div>

    <br style="line-height:2px"/>

     

    <iframe id="IFRAME_acclui"

                frameborder="0"

                onreadystatechange="OnAddressLookupReady();"

                src="/<%=Request["orgname"]%>/sfa/accts/areas.aspx?oId=<%=Request["accid"]%>&oType=1&security=<%=Request["sec"]%>&tabSet=areaAddresses"

                style="width: 100%; height: 85%"

                name="IFRAME_acclui">

    </iframe>

     

    <hr/>

    <input class="btn" onclick="CopyAddress();window.close();" type="button" value="Copy Address">

    </body>

    </html>

     

    That’s about it.

    Wednesday, August 27, 2008 10:32 PM
  • We used this, easy to implement and it works great.

     

    http://www.stunnware.com/crm2/topic.aspx?id=JS26

     

    • Proposed as answer by LachlanF Friday, February 6, 2009 1:43 AM
    • Marked as answer by Donna EdwardsMVP Tuesday, May 5, 2009 8:04 PM
    Wednesday, September 3, 2008 2:32 AM