I am migrating my solution from CRM 8.2 to CRM v9. I am trying to retrieve multiple records in CRM. The same JavaScript code that I am using in my CRM v9 environment was working fine when I was using this in CRM 8.2 environment.
In CRM v9 I am getting following error
TypeError: Cannot read property 'Page' of undefined at eval (eval at (http://vtdemo/VTd365dev/WebResources/vrp_/Disposition/js/Disposition.js:13:1), :1:20) at HTMLDocument. (http://vtdemo/VTd365dev/WebResources/vrp_/Disposition/js/Disposition.js:13:1) at j (http://vtdemo/VTd365dev/WebResources/vrp_/Common/js/jquery_1.11.2.js:2:27295) at Object.fireWith [as resolveWith] (http://vtdemo/VTd365dev/WebResources/vrp_/Common/js/jquery_1.11.2.js:2:28108) at Function.ready (http://vtdemo/VTd365dev/WebResources/vrp_/Common/js/jquery_1.11.2.js:2:29942) at HTMLDocument.J (http://vtdemo/VTd365dev/WebResources/vrp_/Common/js/jquery_1.11.2.js:2:30308)
I do not know why is this happening. May be this thing is not supported in CRM v9 anymore if that is the case then how i can make it work?
I am using below code where error is coming,
var userLcid = Xrm.Page.context.getUserLcid();
I have achieved the desired result by first importing the library inside my HTML web resource,
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
And after some research, I found out that the GetGlobalContext function returns the same context object found in the Xrm.Page.context.
So, then I used it in my JS like below,
var context = GetGlobalContext();
var userLcid= context.getUserLcid();
And it worked fine and I achieved my result.
PS: Thank you all for the support.