locked
Clone Sales Order Detail RRS feed

  • Question

  • I'm trying to clone a sales order detail line.  I have this page opening from a button on the form, the new form opens but it's blank.  It should contain some details from the previous page.  Any ideas what may be wrong with it.  I've included the code from the page:-

     

     

    <html>

    <title>Clone salesorderdetail</title>

    <style>

    BODY, TD

    {

    font-family: arial;

    font-size: 12px;

    }

    TD.body

    {

    bsalesorderdetail-bottom: solid 1px #cccccc;

    text-align: center;

    }

    </style>

    <script language="javascript">

    //Copyright 2006 Microsoft Corporation

    //All Rights Reserved

    //Provided As-Is with no support

    // Set global variable for the cloned salesorderdetail window

    var oClonedsalesorderdetail;

    function window.onload()

    {

    // Open a new salesorderdetail form

    oClonedsalesorderdetail = window.open('/sfa/salesorderdetail/edit.aspx','','menubar=0, status=1, width=1000, height=600');

    // Set a timeout to wait for the new contact form to load

    setTimeout('checkPageState()',100);

    }

    // Checks if the new salesorderdetail form has completed loading

    // When it completes, Clonesalesorderdetail will be called

    // If it's not loaded, it will set a timeout and check again.

    function checkPageState()

    {

    if (oClonedsalesorderdetail.document.readyState == 'complete')

    {

    Clonesalesorderdetail();

    return;

    }

    setTimeout('checkPageState()',100);

    }

    function Clonesalesorderdetail()

    {

    // Get a pointer to the parent window

    var oParent = window.dialogArguments;

    var oSource = oParent.document.crmForm;

    //Set the Master salesorderdetail to True to allow for ease of searching

    oSource.new_mastersalesorderdetail.DataValue = true;

    // With the target crmForm

    with(oClonedsalesorderdetail.document.crmForm)

    {

    // Overview fields

    //Here we are skipping the ticketnumber field as it will be auto populated

    //ticketnumber.DataValue = oSource.ticketnumber.DataValue;

    // Assignment Information

    //ownerid.DataValue = oSource.ownerid.DataValue;

    //followupby.DataValue = oSource.followupby.DataValue;

    // Contract and Product Information

    //contractid.DataValue = oSource.contractid.DataValue;

    //contractdetailid.DataValue = oSource.contractdetailid.DataValue;

    productid.DataValue = oSource.productid.DataValue;

    quantity.DataValue = oSource.quantity.DataValue;

    // productserialnumber.DataValue = oSource.productserialnumber.DataValue;

    // Master salesorderdetail

    new_mastersalesorderdetail.DataValue = oSource.new_mastersalesorderdetail.DataValue;

    }

    // Finally, close the dialog

    window.close();

    }

    </script>

    <body>

    <table width="100%" height="100%" salesorderdetail="0" cellpadding="0" cellspacing="0" align>

    <tr valign="middle">

    <td class="body" align="center">

    <div style="font-size= 10pt; font-family= Tahoma;">Cloning Support Contract</div>

    </td>

    </tr>

    </table>

    </body>

    </html>

     


    Thanks!!

    Friday, December 5, 2008 5:19 PM

Answers

  • There is sample code in the SDK to retrieve values from the window.opener.  Rather than design your own page which opens a new form, you could jsut put code in the onload event of your contract detail page to retrieve the master record's values, like this:

    //only do this with a create form
    if (crmForm.FormType == 1)
    {
    //make sure the opener exists
    if (window.opener)
    {
    var masterForm = window.opener.document.all.crmForm;
    //make sure the master form exists
    if (masterForm)
    {
    //if the user clicked the button
    if (masterForm.all.new_mastersalesorderdetail.DataValue == true)
    {
    crmForm.all.productid.DataValue = masterForm.all.productid.DataValue;
    crmForm.all.quantity.DataValue = masterForm.all.quantity.DataValue;
    }
    }
    }
    }

    and then you can use this code for your button in isv.config:
            <ToolBar ValidForCreate="0" ValidForUpdate="1">
                 <Button JavaScript="crmForm.all.new_mastersalesorderdetail.DataValue = true; window.open('/sfa/salesorderdetail/edit.aspx', '_blank', 'left=20,top=20,width=1000,height=600,toolbar=0,status=0,resizable=1');" ValidForCreate="0" ValidForUpdate="1" AvailableOffline="false">
                   <Titles>
                     <Title LCID="1033" Text="Clone record" />
                   </Titles>
                 </Button>
              </ToolBar>

    The javascript on the button first sets the master sales order detail field to true, then opens a new salesorderdetail form.

    • Marked as answer by Jim Glass Jr Monday, April 20, 2009 7:20 PM
    Monday, April 20, 2009 3:56 PM

All replies

  • There is a clone record example in the SDK you may want to check out.

    Monday, April 20, 2009 11:43 AM
    Moderator
  • There is sample code in the SDK to retrieve values from the window.opener.  Rather than design your own page which opens a new form, you could jsut put code in the onload event of your contract detail page to retrieve the master record's values, like this:

    //only do this with a create form
    if (crmForm.FormType == 1)
    {
    //make sure the opener exists
    if (window.opener)
    {
    var masterForm = window.opener.document.all.crmForm;
    //make sure the master form exists
    if (masterForm)
    {
    //if the user clicked the button
    if (masterForm.all.new_mastersalesorderdetail.DataValue == true)
    {
    crmForm.all.productid.DataValue = masterForm.all.productid.DataValue;
    crmForm.all.quantity.DataValue = masterForm.all.quantity.DataValue;
    }
    }
    }
    }

    and then you can use this code for your button in isv.config:
            <ToolBar ValidForCreate="0" ValidForUpdate="1">
                 <Button JavaScript="crmForm.all.new_mastersalesorderdetail.DataValue = true; window.open('/sfa/salesorderdetail/edit.aspx', '_blank', 'left=20,top=20,width=1000,height=600,toolbar=0,status=0,resizable=1');" ValidForCreate="0" ValidForUpdate="1" AvailableOffline="false">
                   <Titles>
                     <Title LCID="1033" Text="Clone record" />
                   </Titles>
                 </Button>
              </ToolBar>

    The javascript on the button first sets the master sales order detail field to true, then opens a new salesorderdetail form.

    • Marked as answer by Jim Glass Jr Monday, April 20, 2009 7:20 PM
    Monday, April 20, 2009 3:56 PM