Page 1 of 1
Cannot read property 'replaceChild' of null
Posted: 03 Dec 2019
by ksertkaya
Hi,
I have 2 related-item. I get below error when I edit an item. How can I fix this issue?
Best regards.
Code: Select all
setHash();
setHash2();
function setHash(){
fd.field('Year').readonly(true);
var d = new Date();
var yil = d.getFullYear();
value = encodeURIComponent(escape(yil)).replace(/\-/g, "%252D");
window.location.hash = "InplviewHash" + $(".ncrTable [webpartid]").attr("webpartid") + '=FilterField=Year-FilterValue=' + value;
}
function setHash2(){
var d = new Date();
var yil = fd.field('Year').value();
var hash = window.location.hash;
value = encodeURIComponent(escape(yil)).replace(/\-/g, "%252D");
window.location.hash = hash + "#InplviewHash" + $(".indirectNcrTable [webpartid]").attr("webpartid") + '=FilterField=Year-FilterValue=' + value;
}
Re: Cannot read property 'replaceChild' of null
Posted: 04 Dec 2019
by mnikitina
Hello ksertkaya,
This error means that you are accessing a property of an object that is null. But in the code provided there is no 'replcaeChild' property.
Is that a complete code that you have in the form?
Could you please share all code so I could troubleshoot the issue.
Re: Cannot read property 'replaceChild' of null
Posted: 09 Dec 2019
by ksertkaya
Code: Select all
setHash();
setHash2();
function setHash(){
fd.field('Year').readonly(true);
var d = new Date();
var yil = d.getFullYear();
value = encodeURIComponent(escape(yil)).replace(/\-/g, "%252D");
window.location.hash = "InplviewHash" + $(".ncrTable [webpartid]").attr("webpartid") + '=FilterField=Year-FilterValue=' + value;
}
function setHash2(){
var d = new Date();
var yil = fd.field('Year').value();
var hash = window.location.hash;
value = encodeURIComponent(escape(yil)).replace(/\-/g, "%252D");
window.location.hash = hash + "#InplviewHash" + $(".indirectNcrTable [webpartid]").attr("webpartid") + '=FilterField=Year-FilterValue=' + value;
}
Re: Cannot read property 'replaceChild' of null
Posted: 09 Dec 2019
by mnikitina
Hello ksertkaya,
Thank you for the provided code.
I don't think that the error is caused by this code. You can remove it and check if the error still occurs.
Re: Cannot read property 'replaceChild' of null
Posted: 10 Dec 2019
by ksertkaya
When I remove it, not error occurs.
Re: Cannot read property 'replaceChild' of null
Posted: 11 Dec 2019
by mnikitina
ksertkaya,
What is the type of the 'Year' field? Is it a text field or drop-down?
What is the field type of the Year field in the related items?
Related items are List items or Library documents?
Could you please share the screenshot of the form, so I will have the full picture.
Re: Cannot read property 'replaceChild' of null
Posted: 13 Dec 2019
by ksertkaya
Year is number field.
Code: Select all
function IsCurrentUserMemberOfGroup(groupName, OnComplete) {
var currentContext = new SP.ClientContext.get_current();
var currentWeb = currentContext.get_web();
var currentUser = currentContext.get_web().get_currentUser();
currentContext.load(currentUser);
var allGroups = currentWeb.get_siteGroups();
currentContext.load(allGroups);
var group = allGroups.getByName(groupName);
currentContext.load(group);
var groupUsers = group.get_users();
currentContext.load(groupUsers);
currentContext.executeQueryAsync(OnSuccess,OnFailure);
function OnSuccess(sender, args) {
var userInGroup = false;
var groupUserEnumerator = groupUsers.getEnumerator();
while (groupUserEnumerator.moveNext()) {
var groupUser = groupUserEnumerator.get_current();
if (groupUser.get_id() == currentUser.get_id()) {
userInGroup = true;
break;
}
}
OnComplete(userInGroup);
}
function OnFailure(sender, args) {
OnComplete(false);
}
}
function IsCurrentUserHasContribPerms()
{
setHash();
setHash2();
IsCurrentUserMemberOfGroup("Procurement Members", function (isCurrentUserInGroup) {
if(isCurrentUserInGroup)
{
$('.readOnly').find('input,textarea,select').attr('disabled', false);
$('#fd_tabcontrol-0').tabs('option', 'disabled',null);
fd.field('Year').readonly(true);
}
});
}
ExecuteOrDelayUntilScriptLoaded(IsCurrentUserHasContribPerms, 'SP.js');
Re: Cannot read property 'replaceChild' of null
Posted: 16 Dec 2019
by mnikitina
Hello ksertkaya,
The code provided works with no errors.
Is that the complete code?
Could you please share all the script that you have in the form so I could help.
Thank you!