locked
CRM 2011 javascript question RRS feed

  • Question

  • We are planning to upgrade to CRM 2011.  To upgrade to CRM 2011 i need to convert some Javascript from CRM 4 to CRM 2011. The problem is i keep recieving errors and i hope one of you can help me fix the problem.

    Some informatie about what we are doing:
    We are filling 2 iframes based on 2 different entities on the account form. So we are trying to add the e-mail address behind the following link http://tools.nod32.nl/deskpro_export/?search=. And the account number behind the link ttp://10.2.10.13:81/Invoices/invoices.aspx?d=. 

    I am currently useing the following javascript: 

     

    function Form_onload()
    {

    var urltickets = "http://tools.nod32.nl/deskpro_export/?search=";
    var urlfacturen = "http://10.2.10.13:81/Invoices/invoices.aspx?d="; 

     

    var emailsupport = Xrm.Page.getAttribute("don_emailsupport").getValue();
    var email = Xrm.Page.getAttribute("emailaddress1").getValue();
    var debiteurnummer = Xrm.Page.getAttribute("accountnumber").getValue();

    newMyFacturenUrl = urlfacturen + debiteurnummer;
    Xrm.Page.getControl("IFRAME_Facturen").setSrc(newMyFacturenUrl);

     

    if (emailsupport == null)
    {
    newMySiteUrl = urltickets + email;
    }

    else
    {
    newMySiteUrl = urltickets + emailsupport;
    }

    Xrm.Page.getControl("IFRAME_Tickets").setSrc(newMySiteUrl);
    }

     

    What am i doing wrong here? 

     

    Regards Marco


    Wednesday, May 25, 2011 9:26 AM

Answers

All replies

  • Hi,

    Try this fix code:

    function Form_onload()
    {
     
    var urltickets = "http://tools.nod32.nl/deskpro_export/?search=";
    var urlfacturen = "http://10.2.10.13:81/Invoices/invoices.aspx?d="; 

     
    var emailsupport = Xrm.Page.data.entity.attributes.get("don_emailsupport").getValue();
    var email = Xrm.Page.data.entity.attributes.get("emailaddress1").getValue();
    var debiteurnummer = Xrm.Page.data.entity.attributes.get("accountnumber").getValue();
     
    newMyFacturenUrl = urlfacturen + debiteurnummer;
    Xrm.Page.ui.controls.get("IFRAME_Facturen").setSrc(newMyFacturenUrl);
     
     
     
    if (emailsupport == null)
    {
      newMySiteUrl = urltickets + email;
    }
     
    else
    {
      newMySiteUrl = urltickets + emailsupport;
    }
     
     Xrm.Page.ui.controls.get("IFRAME_Tickets").setSrc(newMySiteUrl);
    }

    Please mark as answer if you find the reply useful.

    Thank You,

    Jehanzeb Javeed,

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    Wednesday, May 25, 2011 10:03 AM
  • J.Javeed thanks for your fast reply. 

     

    The code is not working. I have shorted the code to the following: 

     

    function Form_onload()

    {

    var urltickets = "http://tools.nod32.nl/deskpro_export/?search=";
    var email = Xrm.Page.data.entity.attributes.get("emailaddress1").getValue();

    newMySiteUrl = urltickets + email; 

    Xrm.Page.ui.controls.get("IFRAME_Test").setSrc(newMySiteUrl);

    }

    Just to get something working but this simple code is also giving the following error:
    Error: 'Xrm.Page.ui.controls.get(...)' is null or not an object.

     


    Wednesday, May 25, 2011 11:44 AM
  • Xrm.Page.getControl should be fine. Try my CRM4 to CRM 2011 JavaScript Converter tool from the link below and see if the results work for you.


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Useful Tools  CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM Forum Guidance on how to Help Us Help You
    Wednesday, May 25, 2011 11:58 AM
    Moderator
  • Got it working with the following code! 

     

    function Form_onload()

    {

    var urltickets = "http://tools.nod32.nl/deskpro_export/?search=";

    var urlfacturen = "http://10.2.10.13:81/Invoices/invoices.aspx?d=";

    var emailsupport = Xrm.Page.data.entity.attributes.get("don_emailsupport").getValue()

    var email = Xrm.Page.data.entity.attributes.get("emailaddress1").getValue();

    var debiteurnummer = Xrm.Page.data.entity.attributes.get("accountnumber").getValue();

     

    newMyFacturenUrl = urlfacturen + debiteurnummer;

    Xrm.Page.ui.controls.get("IFRAME_Facturen").setSrc(newMyFacturenUrl);

     

     

    if (emailsupport == null)

    {

    newMySiteUrl = urltickets + email;

    }

     

    else

    {

    newMySiteUrl = urltickets + emailsupport;

    }

    Xrm.Page.ui.controls.get("IFRAME_TEST").setSrc(urltickets);

    }

     

    Thanks J.Javeed you solved my problem! 

     

    Wednesday, May 25, 2011 12:21 PM