Announcements
I'm upgrading some js code and I'm trying to replace this
Xrm.Page.context.prependOrgName("myfile");
with this
var context = Xrm.Utility.getGlobalContext();
context.userSettings.prependOrgName("myfile");
However i'm getting this error
TypeError: Xrm.Utility.getGlobalContext is not a function in functionName
This is a js web resource that I'm trying to run it in.The js is ran onload
Has anyone seen this before?
It’s a js file
yeah
whe you say webresource do you mean to a HTML or a JS file?
try opening console dev tools form your browser and write that line of code and it should return an object
if is just a JS file that you want to set on a form and you can't then you should rise a ticket to Microsoft
Hello,
What is the version of Dynamics 365?
In order to troubleshoot, you can open debugger (pressing F12) and run the code directly from the console to check what is available.
Please follow this guide as example: carldesouza.com/.../
Hope this helps you.
Please mark the answer as verified if helpful. That will help others in future.
Thanks
can I add that script tag into a ha webtrespurce?
Hi, if you are using that in a webresource might be just context that does not nothing about Xrm object...
you cand add this tag
<script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
now in your script could be in same html or external JS
<script type="text/javascript">
var Xrm;
(function(){
Xrm = Xrm || parent.Xrm;
})
function yourAwesomeFunction(){
var context = Xrm.Utility.getGlobalContext();
}
</script>
here more detailied
community.dynamics.com/.../typeerror-xrm-utility-getglobalcontext-is-not-a-function
André Arnaud de Cal...
294,233
Super User 2025 Season 1
Martin Dráb
232,982
Most Valuable Professional
nmaenpaa
101,158
Moderator