locked
how to access crm form attribute from iframe (aspx page) in dynamics crm 2015 RRS feed

  • Question

  • Hi,

    I created a aspx page which contains a textbox and a search button.

    input:  search text and validate to find the corresponding contract

    output: update on the crm form the value of the contract found from iframe.

    Thanks for your help.

    Regards

    i need to set the crm form customerid value which are commented in the sample

    ps: sample --

    aspx

    <%

    @PageLanguage="C#"AutoEventWireup="true"CodeBehind="searchbycontractnum.aspx.cs"Inherits="MSCRM_ISV_MIGRA.cs.contracts.searchbycontractnum"%>



    <!

    DOCTYPEhtml>

    <

    htmlxmlns="http://www.w3.org/1999/xhtml">

    <

    headrunat="server">

    <

    metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/>


       

    <title></title>

       

    <scripttype="text/javascript">

     

    // Recupère le compte qui contient le nom le compte et l'id iddcompte


             

    functionretrievecompte(idducompte) {


    if(parent.Xrm.Page.getControl("IFRAME_SearchByContract") != null) {

     //window.parent.Xrm.Page.getAttribute("customerid").setValue(idducompte);

    //window.parent.Xrm.Page.getAttribute("customerid").fireOnChange();

                      alert(

    'bonjour : iframe ');

     

     

                  }

    else{

    //window.parent.Xrm.Page.getAttribute("customerid").setValue(idducompte);

    //window.parent.Xrm.Page.getAttribute("customerid").fireOnChange();

                      alert(

    'bonjour : non iframe ');



           }




              }

             



    </script>


             


    </

    head>

    <

    body>


    <formid="form1"runat="server">

    <asp:ScriptManagerID="ScriptManager1"runat="server"OnAsyncPostBackError="ScriptManager1_AsyncPostBackError">

    </asp:ScriptManager>


    <asp:UpdatePanelrunat="server"ID="main">

     

    <ContentTemplate>

     

    <div>

            

    <asp:Panelrunat="server"ID="panelform1"defaultbutton="searchbybtnId">

              

    <asp:LabelID="searchbylbl"runat="server"Text="Entrez le numéro de contrat :"/>

               

    <asp:TextBoxID="searchbynumcontratId"runat="server"/>

               

    <asp:ImageButtonImageUrl="~/img/16_find.gif"ID="searchbybtnId"runat="server"

                       

    Style="height: 16px;"Onclick="searchbybtnId_Click"  />

                       

    </asp:Panel>


               

    </div>

         

    </ContentTemplate>

     

    </asp:UpdatePanel>

        

    <divstyle="width: 578px; height: 40px; overflow: auto;">

                   

    <asp:PlaceHolderID="errorHolder"runat="server"/>

          

    </div>


       

    </form>

    </

    body>

    </

    html>

    asp.cs:

    Friday, May 27, 2016 9:16 AM

All replies

  • sample for the code behind:

    protectedvoidsearchbybtnId_Click(objectsender, EventArgse)

            {       

    try

                {

                   

    //Récupération du contrat et du compte correspondant

    //TODO voir s'il n'y a pas une autre solution

                  

    Entitymoncontrat = RetrieveContrat(searchbynumcontratId.Text);

                          

    EntityReferencecompteId = (EntityReference)moncontrat["customerid"];

                

    stringlecompte = compteId.Id.ToString();

        

    ScriptManager.RegisterStartupScript(this, this.GetType(), "search", "retrievecompte('"+ compteId.Id + "');", true);

                  


                }

               

    catch(Exceptionex)

                {           

    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Message erreur : --- "+ ex.ToString() + "');", true);

                }

            }

    Friday, May 27, 2016 9:16 AM
  • the problem is that your page is asp.net and you are probably hosting it in a different site (domain), so you will end up with forbidden cross references between your iframe and the crm.

    My blog: www.crmanswers.net - CRM Theme Generator

    Friday, May 27, 2016 9:42 AM
  • yes Guido, the isv is unsupported, so i created another web site and made all extensions ( the aspx page ). Now i can communicate with my iframe no problem i just can not set a value into the crm form

    what can i do?

    here is the structure on iis. my aspx page is into crm15 web site

    thanks


    • Edited by dc74 Friday, May 27, 2016 11:35 AM texte correction
    Friday, May 27, 2016 10:07 AM
  • hello,

    So what can i do to resolve this problem?

    Thanks

    Regards

    Tuesday, June 7, 2016 8:57 AM