Cannot read property 'replaceChild' of null

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ksertkaya
Posts: 87
Joined: Wed Nov 18, 2015

03 Dec 2019

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;
}
Attachments
Screenshot_26.png
Screenshot_26.png (17.53 KiB) Viewed 3328 times
Last edited by ksertkaya on 09 Dec 2019, edited 1 time in total.

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

04 Dec 2019

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.

ksertkaya
Posts: 87
Joined: Wed Nov 18, 2015

09 Dec 2019

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;
}

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

09 Dec 2019

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.

ksertkaya
Posts: 87
Joined: Wed Nov 18, 2015

10 Dec 2019

When I remove it, not error occurs.

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

11 Dec 2019

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.

ksertkaya
Posts: 87
Joined: Wed Nov 18, 2015

13 Dec 2019

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');
Attachments
Screenshot_29.png
Screenshot_29.png (19.28 KiB) Viewed 3283 times

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

16 Dec 2019

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!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests