Hi all,
When I open any opportunity form I get the following js error: Cannot read property 'getCurrentItem' of null.
Investigating the problem and reading call stack I've got some details:
Stack trace:
renderOlderPosts (JsProvider.ashx?bundle=ActivitiesFeedsBundle&ids=1469705066-1731109441-213957365-330369912-20406073…:1252)
processRetrievePostsResponse (JsProvider.ashx?bundle=FormControlExtendedBundle&ids=202888856-493509602:formatted:556)
loadPosts (JsProvider.ashx?bundle=ActivitiesFeedsBundle&ids=1469705066-1731109441-213957365-330369912-20406073…:1318)
(anonymous) (MicrosoftAjax.js?ver=987093208:24)
(anonymous) (JsProvider.ashx?bundle=FormControlExtendedBundle&ids=202888856-493509602:formatted:1161)
readyStateChanged (JsProvider.ashx?bundle=CoreBundle&ids=1401263868-1250882489-468302605-1405388298-1194605645-3425196…:663)
Function where error is caused (renderOlderPosts):
renderOlderPosts: function() {
var $v_0 = this.wallContainerjQuery.find(".showMoreLink");
$v_0.addClass("showMoreLinkProgress");
this.$3_0 = 3;
var $v_1 = this.$0_0.getWallServiceFactory().createRetrievePostsRequest();
$v_1.set_pageSize(this.$8_0);
$v_1.set_endDate(this.$H_0);
$v_1.set_pagingCookie(this.$A_0);
this.$5_0++;
$v_1.set_pageNumber(this.$5_0);
var $v_2 = {
page: this.$5_0,
wallType: this.rootContainer[0].id,
entity: !Xrm.Page.data ? null : Xrm.Page.data.entity.getEntityName(),
form: !Xrm.Page.ui ? null : Xrm.Page.ui.formSelector.getCurrentItem().getId()
};
this.fireEvent(Wall.Interfaces.EventArguments.PostsRefreshingEventArgs, "PostsRefreshing", new Wall.Interfaces.EventArguments.PostsRefreshingEventArgs($v_1));
var $$t_5 = this;
this.$0_0.retrievePosts($v_1, function($p1_0) {
$$t_5.processRetrievePostsResponse($p1_0, function() {
$v_0.removeClass("showMoreLinkProgress").remove();
$$t_5.$3_0 = 1;
var $v_3 = Wall.Control.Utils.WallUtils.removeDuplicatePosts($p1_0.get_posts(), $$t_5.$1_0);
$$t_5.$n_0($v_3);
$p1_0.get_morePosts() && $$t_5.$o_0();
$v_2["posts"] = $v_3.length;
Mscrm.MetricsReporting.instance().addMetric("Wall.LoadMore", $v_2)
}, function() {
$v_0.removeClass("showMoreLinkProgress");
$v_2["posts"] = 0;
Mscrm.MetricsReporting.instance().addMetric("Wall.LoadMore", $v_2)
}, function() {
$v_0.removeClass("showMoreLinkProgress");
$$t_5.$3_0 = 5;
$v_2["error"] = true;
Mscrm.MetricsReporting.instance().addMetric("Wall.LoadMore", $v_2);
alert($p1_0.get_errorMessage())
})
})
}
As we can see from the call stack, this function is a part of ActivityFeedsBundle. (In my installation ActivityFeeds I turned off activity feeds for all entities.)
Error is caused on 15th line where execution context trying to get Id of CurrentItem, where formSelector is null so it is a null reference exception.
Also, as stated here https://community.dynamics.com/crm/b/sohodynamicscrmworld/archive/2013/10/02/microsoft-dynamics-crm-2013-xrm-page-ui-formselector Xrm.Page.ui.formSelector.getCurrentItem() can return null if there's only one form for this entity, so if this happens
Xrm.Page.ui.formSelector.getCurrentItem().getId()
we won't be able to getId() of null.
I think that this is business logic error and needs to be corrected.
Also is there any way to fix this issue without editing ActivitiesFeedsBundle js file.
Thank you in advance.
P.S.: Running full-text search on CRMWeb folder I found this script location:
C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_static\_common\scripts\Wall.Control.js