web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

odata error in IPAD Active x object not found

(0) ShareShare
ReportReport
Posted on by

Hi There

I am getting  activex object not found or not defined error in Ipad only not in desktop versions. I have written a odata script on the appointment form , on change of regarding field   or on load of appointment form, script checks for the regarding  field if its lead gets the company name of lead puts on the appointment form, this is working fine on desktop or laptop versions but not on iPad getting activex object not found or nor defined, below is the script. 

function setcompanyname()
{
var reg = Xrm.Page.getAttribute("regardingobjectid").getValue();
if(reg != null)
{
var regarding = new Array();
var regarding = Xrm.Page.getAttribute("regardingobjectid").getValue();
var regardingText = regarding[0].name;
var regardingId = regarding[0].id;
var regardingType = regarding[0].entityType;

if(regardingType == "lead")
{
var serverUrl = Xrm.Page.context.getServerUrl();
var oDataEndpointUrl = serverUrl +"/XrmServices/2011/OrganizationData.svc/";
oDataEndpointUrl +="LeadSet?$select=CompanyName,FullName&$filter= LeadId eq (guid'" + regardingId + "')";
var service = new ActiveXObject("MSXML2.XMLHTTP.3.0");
if(service != null)
{
service.open("Get",oDataEndpointUrl,false);
service.setRequestHeader("X-Requested-Width","XMLHttpRequest");
service.SetRequestHeader("Accept","application/json,text/javascript, */*");
service.send(null);
var requestResults = eval('('+service.responseText +')').d.results;
if(requestResults != null && requestResults.length >= 1)
{
var LeadEntity = requestResults[0];
var result = null;
//var id = LeadEntity.LeadId
var Name = LeadEntity.FullName;
var CName = LeadEntity.CompanyName;

Xrm.Page.getAttribute("ace_companyname").setValue(CName);
}
}
}
}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    NKC Profile Picture
    on at

    Thanks

  • NKC Profile Picture
    on at

    Hi

    I changed my code to below , how to i retrive the company name attribute for the query and set that company name to  diffrent filed. i want to do this in success call back function.

    function getlead (leadid, successCallback, errorCallback)

    {

       //OData URI to get address information from parent account record  

          var oDataURI = Xrm.Page.context.getClientUrl()

           + "/XRMServices/2011/OrganizationData.svc/"

           + "LeadSet(guid'" + leadid + "')"

           + "?$select="

           + "CompanyName";

       //Asynchronous XMLHttpRequest to retrieve account record    

      var req = new XMLHttpRequest();

       req.open("GET", encodeURI(oDataURI), true);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.onreadystatechange = function ()

       {

           //debugger;      

          if (this.readyState == 4 /* complete */)

          {

               req.onreadystatechange = null; //avoids memory leaks          

               if (this.status == 200)

                   {

                   //parse the response string as a JSON object into the successCallback method.              

                    successCallback(JSON.parse(this.responseText).d);

                   }

               else

                {

                   errorCallback(leadid);

                }

           }

       };

       req.send();

    }

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    Use the below code to set company name to your field ,replace "yourfieldname"

    function getlead (leadid, successCallback, errorCallback)

    {

      //OData URI to get address information from parent account record

         var oDataURI = Xrm.Page.context.getClientUrl()

          + "/XRMServices/2011/OrganizationData.svc/"

          + "LeadSet(guid'" + leadid + "')"

          + "?$select="

          + "CompanyName";

      //Asynchronous XMLHttpRequest to retrieve account record    

     var req = new XMLHttpRequest();

      req.open("GET", encodeURI(oDataURI), true);

      req.setRequestHeader("Accept", "application/json");

      req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

      req.onreadystatechange = function ()

      {

          //debugger;      

         if (this.readyState == 4 /* complete */)

         {

              req.onreadystatechange = null; //avoids memory leaks          

              if (this.status == 200)

                  {

                  //parse the response string as a JSON object into the successCallback method.              

                  //   successCallback(JSON.parse(this.responseText).d);

                  var leadresult = JSON.parse(req.responseText).d;

                  Xrm.Page.getAttribute("yourfieldname").setValue(leadresult.CompanyName);

                  }

              else

               {

                  errorCallback(leadid);

               }

          }

      };

      req.send();

    }

  • NKC Profile Picture
    on at

    Thank you one more question please , if i use below method , this from sdk. i added rest.sdk to my web resources and i am sending parameters from my javascript , below case how do i retrive ComanyName -- which is a attribute on lead. Thanks

    SDK.REST.retrieveRecord(regardingId,"Lead","CompanyName",null,sucesshandler,errorHandler)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans