locked
javascirpt on ipad in mscrm 2013 RRS feed

  • Question

  • Dear all;

    i have a JavaScript on appointment form which working fine on browser but when i use the appointment  form  through ipad it is not working

    Friday, November 15, 2013 12:23 PM

All replies

  • Hi,

    Do you get any script errors? What is it that is not working? Could you post the script that is causing the issue?



    Scott Durow
    Blog www.develop1.net    Follow Me
    Rockstar365
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Friday, November 15, 2013 12:51 PM
    Answerer
  • Hi scott;

    there is no error actually what javascript is doing  if the regarding is account it is fetching the account address and setting it in location field on appointment that is working fine in browser but when it comes to iPad it does not shoe any error but nothing happend

    here is the code

    function set_app_location()
    {

    var txt="";
    var lookupValue = Xrm.Page.getAttribute("regardingobjectid").getValue();
    var loc=Xrm.Page.getAttribute("location").getValue(); 

    // if(loc==null || loc=="")
    // {
    if(lookupValue !=null && lookupValue !="" )
    {
    var subFundId= lookupValue[0].typename;
    var AccId= lookupValue[0].id;
       
       
       if (subFundId=='account')
       
       {
       var ProTypeData = GetAdd(AccId);
       
       
       if (ProTypeData != null && ProTypeData[0] != null) {
       var finaltext;
               if(ProTypeData[0].Address1_Line1!=null)
      {
     
    var line1= ProTypeData[0].Address1_Line1;


    finaltext=line1+", ";



     }
      if(ProTypeData[0].Address1_PostalCode!=null)
      {
     
    var postal= ProTypeData[0].Address1_PostalCode;


    finaltext=finaltext+postal+", ";



     }
        if(ProTypeData[0].Address1_City!=null)
      {
     
    var city= ProTypeData[0].Address1_City;


    finaltext=finaltext+city;



     }
     if(finaltext!=null)
     {
     Xrm.Page.getAttribute("location").setValue(finaltext);
     Xrm.Page.getAttribute("location").setSubmitMode("always");
     
     }
     else
     {
     
      Xrm.Page.getAttribute("location").setValue(null);
       Xrm.Page.getAttribute("location").setSubmitMode("always");
     
     }

     

    }
       
       else
       {
       Xrm.Page.getAttribute("location").setValue(null);
       Xrm.Page.getAttribute("location").setSubmitMode("always");
       
       }
       
       }
       

    }
    else
    {
       Xrm.Page.getAttribute("location").setValue(null);
       Xrm.Page.getAttribute("location").setSubmitMode("always");
       
       }

    // }
    }




    function GetAdd(AccountId) {
           var serverUrl;
    if (Xrm.Utility.alertDialog !== undefined) {
       // CRM 2013
        serverUrl = Xrm.Page.context.getClientUrl();

    else {
       // CRM 2011
        serverUrl = Xrm.Page.context.getServerUrl();
    }
        var oDataUri = serverUrl + "/xrmservices/2011/OrganizationData.svc/AccountSet(guid'" + AccountId + "')?$select=Address1_Line1,Address1_PostalCode,Address1_City";
    var jSonArray = new Array();
    // ,val_Internkommentar
        jQuery.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: oDataUri,
            async: false,
            beforeSend: function (XMLHttpRequest) {
                //Specifying this header ensures that the results will be returned as JSON.            
                XMLHttpRequest.setRequestHeader("Accept", "application/json");
            },
            success: function (data, textStatus, XmlHttpRequest) {
                if (data && data.d != null) {
                    jSonArray.push(data.d);
                }
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                alert("Error :  has occured during retrieval of the Account Address");
            }
        });

        return jSonArray;
    }

    • Edited by anwar_addi Friday, November 15, 2013 1:14 PM
    Friday, November 15, 2013 1:11 PM