locked
Access crm attributes from iframe RRS feed

  • Question

  • i have an iframe in which i have embeded aspx page

    i need one attribute values from the same record in a different tab

    can i access that value from the iframe


    Sunday, February 14, 2010 6:04 AM

Answers

All replies

  • try in javascript in your aspx page.

    window.parent.crmForm.all.someattribute.DataValue = 'Some value from aspx page';
    Sunday, February 14, 2010 6:58 AM
  • it is throwing error "access denied"
    Sunday, February 14, 2010 7:12 AM
  • did you uncheck the box "restrict cross-frame scripting"? while adding  the iframe in the entity customization?
    Sunday, February 14, 2010 7:16 AM
  • yes...................
    Sunday, February 14, 2010 7:21 AM
  • Hi varun, i am able to get & set the values using the below code(just tested myself). could u check your code, may be there is something else  you are trying to do that is causing this error to happened.

    var str = parent.crmForm.all.ca_journalname.DataValue;
    parent.crmForm.all.ca_journalname.DataValue = 'This is a test';
    Sunday, February 14, 2010 7:30 AM
  • i think u are doing it reverse

    i want to access the crm form field in iframe javascript code


    Sunday, February 14, 2010 8:04 AM
  • No varun, i am doing the below code in aspx (loaded inside an  iframe)

    var str = parent.crmForm.all.ca_journalname.DataValue; // get
    parent.crmForm.all.ca_journalname.DataValue = 'This is a test'; // set

    can u put a debugger; statement in your javascript and try to see the value of these attribute values.
    Sunday, February 14, 2010 8:12 AM
  • If your page in iframe in other website this would not be impossible to access parent CRM form attributes.
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    Sunday, February 14, 2010 8:13 AM
    Moderator
  • yeah agreed, with andry,  i think you should configure your asp.net application under isv folder  in MS CRM.
    Sunday, February 14, 2010 8:16 AM
  • The access denied is due to the domain not matching your web app in the iFrame. For example if you have MSCRM on http://myServer:5555 and your Web App in the Iframe is http://192.168.22.22:4444, then the security side of IE is not going to let you do this.

    If you cannot place the web app in the ISV folder and but your web app runs on the same server as MSCRM you could ensure you are using the same address such as http://myServer:5555 (MSCRM) and http://myServer:4444/myapp.aspx (Iframe).

    Sunday, February 14, 2010 12:59 PM
    Moderator
  • the custom application which we are developing is a huge application and i feel if i place the app in the isv folder then everything will be messed up

    and it will be very hard when we try to migrate the application from development to production

    Wednesday, February 24, 2010 7:34 AM
  • Hi varun,
    I am afraid, this will not be possible(putting asp.net applicaiton on separate server and accessing the crmForm).
    I think you may have to put your application under ISV.
    or if you don't want to put your whole  applictation, then at least put the page which is changing MS CRM and the rest of the applicaiton some-where else and modify the navigation in the aspx page according.
    Muhammad Ali Khan
    My MS CRM blog
    Wednesday, February 24, 2010 7:51 AM
  • Hi Varun

    1. Obtain the attribute value (may be in any tab in the form) on the OnLoad event of the form
    2. Form the IFRAME URL along with the parameter of the attribute
    3. Assign the URL to the IFRAME

    OnLoad()

    //Obtain the needed attribute
    var AccountStreet = crmForm.all.address1_line1.DataValue;
    //Create the URL for the IFRAME
    var IframeURL= "http://localhost:12345/home.aspx?strt1=" + AccountStreet";
    //Assign the IFRAME url
    if (IframeURL != null)
       {
          crmForm.all.IFRAME_Map.src = MapURL;
       }


    aspx.cs page:


    Get the value in the aspx.cs page using requset.getParameter("strt1");

    Regards
    Vinoth
    Wednesday, February 24, 2010 8:26 AM
  • but i need the guid and orgname and type which are passed by default also
    Wednesday, February 24, 2010 8:38 AM
  • var oId = crmForm.ObjectId;
    var oType = crmForm.ObjectTypeCode;

    //Obtain the needed attribute
    var AccountStreet = crmForm.all.address1_line1.DataValue;
    //Create the URL for the IFRAME
    var IframeURL= "http://localhost:12345/home.aspx?id="+oID+"type="+oType+"Org="+"CRM"+"strt1="+ AccountStreet";
    //Assign the IFRAME url
    if (IframeURL != null)
       {
          crmForm.all.IFRAME_Map.src = IframeURL;
       }
    Wednesday, February 24, 2010 9:31 AM
  • how do we get the org name dynamically
    Thursday, February 25, 2010 9:19 AM
  • alert("ORG_UNIQUE_NAME="+ORG_UNIQUE_NAME);
    Thursday, February 25, 2010 9:36 AM