locked
Failed : CRM 2011 Access parent form attribute in a Webpage using JScript RRS feed

  • Question

  • In CRM 2011, I am not able to access the Parent form attributes in a external web page using JScript

    I have added a Ribbon button on one Entity,  when I click this button a web page from a asp.net web app deployed on the same CRM server will be shown,

    the following script is part of  web resource which is linked with the Ribbon button

    window.showModalDialog(URL, window, "dialogHeight:700px;dialogWidth:750px;center:yes; resizable:0;maximize:0;minimize:0;status:no;scroll:no");

    when I click the close button on that page, I need to set the parent form attribute value

    I tried all these options suggested in MSDN forum but nothing helped me .. Any idea would be really helpful.

    <script language="javascript">
    var parentWindow = window.dialogArguments;
    alert(parentWindow.name);
    window.close();
    </script>

    ### Result : alert shown "contentIFrame" and window got closed  - just to make sure the script block is working fine.

    but the follwoing are not working...


    var parentWindow = window.dialogArguments;
    parentWindow.Xrm.Page.data.entity.attributes.get('XXXX').setValue('yes');
    window.close();
    ### Result :  No error message , Value not updated, Window not closed.


    window.top.opener.top.getElementById('contentIFrame').contentWindow.Xrm.Page.getAttribute('XXXX').setValue('Yes');
    window.close();
    ### Result :  No error message , value not updated, Window not closed.

    window.top.opener.Xrm.Page.data.entity.attributes.get('XXXX').setValue('xyz');
    window.close();
    ### Result :  No error message , value not updated, Window not closed.

    alert(window.top.opener.document.getElementById("XXXX").value;
    window.close();
    ### Result : No error message , No alert, Window not closed.

    window.top.opener.Xrm.Page.data.entity.attributes.get("XXXX").setValue = "TEST";
    window.close();
    ### Result : No error message , value not updated, Window not closed.


    var oParentCrmForm=window.opener.parent.document.all.crmForm;
    alert(oParentCrmForm.name);
    window.close();
    ### Result : No error message , No alert, Window not closed.

    NOTE  : XXX, I used the exact name with the proper case , tried with schema name too but no luck

    This script is registered like this in the Close Button event

    ClientScriptManager cs = Page.ClientScript;
    Type cstype = this.GetType();
    cs.RegisterStartupScript(cstype, "Updateattribute", script as String, false);

    Regards

    MSK


    • Edited by mgsk Thursday, December 19, 2013 11:13 AM
    Thursday, December 19, 2013 10:59 AM