我创建了一个自定义Web资源来显示数据集合。我正在使用REST端点并将JSON数据转换为div标签。代码按照我的预期工作并显示我的数据,但每当我关闭或刷新表单时,我会弹出一个表示检测到错误的信息。错误如下:
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>Object expected</Message>
<Line>3</Line>
<URL>/%7B634594794180000000%7D/WebResources/RelatedEntities/Scripts/new_library</URL>
<PageURL>/userdefined/edit.aspx?etc=1&id=%7b3A472BF4-3B86-E011-8617-005056980004%7d&pagemode=iframe&sitemappath=Workplace%7cMyWork%7cnav_dashboards</PageURL>
<Function></Function>
<CallStack>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; Microsoft Outlook 14.0.6025)</BrowserUserAgent>
<BrowserLanguage>en-us</BrowserLanguage>
<SystemLanguage>en-us</SystemLanguage>
<UserLanguage>en-us</UserLanguage>
<ScreenResolution>1920x1080</ScreenResolution>
<ClientName>Outlook Laptop - Online</ClientName>
<ClientTime>2011-12-14T09:10:25</ClientTime>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1033</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1033</UserCulture>
<CRMVersion>5.0.9688.1157</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>
WebResources / RelatedEntities / Scripts / new_library是我的.js文件,以:
开头//GetGlobalContext function exists in ClientGlobalContext.js.aspx so the
//host HTML page must have a reference to ClientGlobalContext.js.aspx.
var context = GetGlobalContext();
//Retrieve the server url, which differs on-premise from on-line and
//shouldn't be hard-coded.
var serverUrl = context.getServerUrl();
//The XRM OData end-point
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
所以第3行指的是“var context = GetGlobalContext();”但是为什么在表单关闭/刷新时会导致问题?
我使用我的.js代码作为嵌入资源,并且我没有使用任何CRM事件处理程序。