Xrm object undefined on SiteMap Html web resource in D365 Online - dynamics-crm

I have an Angular html page that has script reference to the javascript. In the Javascript I am using Xrm object to make certain actions like Xrm.webApi.retrieveMultipleRecords etc..
This Angular Html Web resource is loaded as part of SiteMap. The Angular Html web resource also have script reference to "ClientGlobalContext.js.aspx" and able to access Xrm object.
If I remove the aspx script reference the Xrm object is undefined. Microsoft docs mention that this script reference doesn't make the Xrm object available but in my case it's exactly what it is doing.
Then I tried removing the "ClientGlobalContext.js.aspx" reference and started using parent.Xrm object and everything seems to be working fine again. But the Microsoft docs again said that parent.Xrm will not work if loading an HTML web resource as part of SiteMap which exactly is my scenario and seems to be working.
So need to know what I should do as I don't want to use any methods that's going to be deprecated.
Here is the link to the Microsoft docs: Screenshot of the issue
https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/getglobalcontext-clientglobalcontext.js.aspx

I had a similar problem using Xrm.WebApi object in a Web Resource as well.
See here: Using Xrm.WebApi method in Web Resource opened in a new window
The short answer is, is that the methods rely on JavaScript constants that are only loaded on the CRM pages. You can work-around the issue by providing your own constants, and copy the values from window.opener.top.

Related

Modifying the WCF/REST or JSON help page

When a WCF/REST or JSON service is created in Visual Studio with helpEnabled="true" in the web config, there will be a URL similar to "https://Server/Service/ServiceREST.svc/help". IIS will present a help page - see enclosed example.
I'm looking to modify this page, I want to exclude some lines.
Does anyone know how, or if that is possible?
According to your description, I would like to tell you that the help page of WCF WebHttp endpoint cannot be modified, and in fact there is no property or configuration to control it. You can replace it with your own custom page, but this requires writing a lot of code according to your needs. You can read about the schemas used in the WCF Web HTTP Services help page through this document.

Microsoft translator widget not translating contents loaded dynamically(e.g. using ajax call)

We are trying to understand different language translation options for our mvc application.
We checked how Microsoft translator widget working. As per their document, we have added embedded script to our pages. It loaded translate button. it is translating content to selected language. But then after if any content loaded dynamically (e.g. making ajax call and loaded some partials in the page), it is not automatically convert to language. We need to again reset and re-select the language to convert again.
Note: In case of google translate widget, they are converting automatically all dynamic content after loading them.
We want same functionality using Microsoft translator widget. Is there any way to achieve this functionality?
Yes there is, Microsoft no longer supports the Translator widget and the available solution is to integrate the Translator Text API in your website or application. To do this you will need to subscribe to the Microsoft Translator Text API. Visit the Getting Started page at http://www.aka.ms/TranslatorGettingStarted and you will find the steps.

Google API file not found on local document from scripts created by the API on page load

I'm using Electron to build a desktop app that uses the YouTube Data API to get information. The problem is that, when my page loads, I am met with four net::ERR_FILE_NOT_FOUND errors. It's trying to get file://ssl.gstatic.com/s2/oz/images/stars/po/bubblev1/bubbleDropR_3.png and a couple others of the same ilk, all of which obviously do not exist. I am not loading the apis from a relateive path; how can I fix this?
EDIT: I should note that the source of the errors appear to be scripts being loaded in the page's <head>. These were not loaded by me and were put there when the API loaded.

how to integrate ajax to my project

What do i need to do for putting ajax functionality to my project.
What tool kit do i need to download or how can i integrate that .
and do i really need to do something for putting update panel for my project?
One method for AJAX enabling your ASP sites is using the AJAX control toolkit (http://www.asp.net/ajax/ajaxcontroltoolkit/samples/) which provides some AJAX functionality using ASP controls that should be familiar to a novice Dot Net developer. AJAX Control Toolkit is a DLL you add to your solution just like other controls. There is then markup for use in the ASP.NET pages.
For more customized and advanced AJAX features, your best bet is using JQuery (http://jquery.com/) and create *.asmx Web Services. JQuery includes a $.ajax() call that will communicate to ASP.NET Web Services using JSON. This SO page may help - Calling ASMX from jQuery and this Encosia blog entry may help - http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/. JQuery is a library of JavaScript files that you download, include in your page, and call into using your own JavaScript files.
I would also recommend that you read the wikipedia entry for AJAX (http://en.wikipedia.org/wiki/Ajax_(programming)) and familiarize yourself with the related technologies.
I think you need to provide a lot more information before we can give youa definitive answer.
Ajax is simply using Javascript to request a webpage - same as a user clicking on a link - except that JavaScript gets the contents of the page requested instead of showing it to the user.
This allows you to request data within JavaScript without refreshing the page.
As you mentioned UpdatePanel, I'm assuming you're using ASP.Net - In which case, .Net 2.0 didn't include AJAX and you needed to get some additional installs to make it work. 3.5 and later includes it natively.
If you're just starting to get into the whole area, I suggest you do some reading about how AJAX works behind the scenes before trying to use it - Understanding what its doing will save you a LOT of headaches later.
FWIW you don't actually need ANYTHING special to make AJAX work - you can write it yourself entirely in JavaScript (I've done this far too many times). As mentioned in Doug's answer, JQuery is fantastic and is worth using even without the AJAX functionality.
If, however, you want to use UpdatePanels and AJAX, the easiest option is .Net 3.5 or later (Visual Studio 2008 or later)
In my opinion, jQuery has the best AJAX functionality and is easy to learn and use. It's got great documentation and there are lots of tutorials and examples -- I love it.

Oracle CRM OnDemand custom web applet - add User object variables to URL

I have a custom web applet that I am adding to the Lead object tab of my Oracle CRM On Demand app. It is easy to include a variable in the URL via the %%%VARIABLE_NAME%%% convention but that seems to only work with the object itelse (Lead, Service Request, etc) Since the field I want to add is part of a different object (the User) it doesnt seem to be working.
Any help on how to add this would be greatly appreciated.
Here it talks about custom web applets, and under Fields it talks about adding a variable:
http://download.oracle.com/docs/cd/E14388_01/books/OnDemOLH/index.htm?toc.htm?creatingcwa.html
I got a definitive "not possible" from an oracle web service developer on this issue.
So turns out that in a custom web applet for one object you cannot have custom fields from other objects.
My work-around is to pass the unique userid %%%User id%%% back to my app and work from there.

Resources