1

I am working on an enterprise wiki site collection, now when the user edit the properties of the page he will be redirected to the following page :-

enter image description here

so i wanted to hide all the fields except the Name and title, so inside our testing server i edit the page then i added the following code snippet :-

<script>

$('#formTbl tr').filter(function () 
{
return !$(".ms-standardheader", this).text().match(/Name|Title/i);
}).remove();

</script>

where it hide the unwanted fields. now i did the same steps on our live server but the script raised the following error:-

SCRIPT5007: Unable to set property 'ListId' of undefined or null reference EditForm.aspx, line 1230 character 1

so can anyone advice on this please ?

4
  • It seems there is some other script error on the page. Remove you custom script and see what is causing this error. – Amal Hashim Apr 28 '15 at 15:44
  • if i remove the custom script no errors will be raised... – john Gu Apr 28 '15 at 15:44
  • can you adivce more on this ? where i need to add this ? – john Gu Apr 28 '15 at 15:53
  • I added it as an answer. Hope it works. – Amal Hashim Apr 28 '15 at 15:54
1

Try

<script>
$(document).ready(function(){
    $('#formTbl tr').filter(function () 
    {
        return !$(".ms-standardheader", this).text().match(/Name|Title/i);
    }).remove();
});
</script>
5
  • thanks using your code i was able to hide the unwanted fields , but i am getting this error now :-SCRIPT5007: Unable to set property 'AllowWebParts' of undefined or null reference – john Gu Apr 28 '15 at 16:02
  • 1
    Ok instead of .remove.. try .hide() – Amal Hashim Apr 28 '15 at 16:03
  • using .hide() worked well, but now i am 100% confused , as my original script worked well on the testing server , but it did not work on the live server, so what could be the reason behind this ? second question, why using .hide instead of .remove solve the second problem ? – john Gu Apr 28 '15 at 16:10
  • Error says null reference.. This happens when object is not found.. In your case remove might have cause this.. These where all guess and luckily it worked. Not sure about why it happened only in Live. – Amal Hashim Apr 28 '15 at 16:11
  • now i move your code to the testing server and it worked .. – john Gu Apr 28 '15 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.