1

I am working on an enterprise wiki site collection inside sharepoint 2013 farm. i have a custom date field named "ExpireDate", and i added a validation inside the Pages library's Validation settings, to force the "ExpireDate" to be in the future as follow:-

enter image description here

but when i tried to create a new wiki page i got this error, so now i am unable to create new wiki pages unless i remove the validation:- enter image description here

so can anyone advice on what is the correct way to add field validations for our enterprise wiki pages? should i add the validation inside the page layout instead of using the Validation setting inside the pages library ?

2
+25

I too can reproduce, but the only workaround is not to use OOB validation.

The only alternative I can think of is to use JavaScript. Put something like the following in a script editor web part on the new and edit forms:

<script type="text/javascript">
    function PreSaveAction() {
        var input = document.querySelector("input[id^='ExpireDate_']");
        if(input && input.value) {
            var expires = new Date(input.value);
            var today = new Date();
            today.setHours(0,0,0,0);
            if(!(expires > today)) {
                alert("Expires must be greater than today!");
            }
            return expires > today;
        }
        return true;
    }
</script>

Note that his will not validate if the field is empty, but you can configure it as a required field if you want to prevent empties.

  • thanks for your reply .. when it comes to enterprise wikis we edit the pages using page layouts and not regular edit forms, so will your script work inside the page layout (enterprisewiki.aspx page layout used inside enterprise wiki site collections)? – SharePoint TestDev Jun 10 at 15:42
  • here is the field inside the page layout <SharePoint:DateTimeField FieldName="5597d368-6f9d-4983-84e5-fa48f40a7a3f" runat="server"></SharePoint:DateTimeField> – SharePoint TestDev Jun 10 at 16:08
  • 1
    Unfortunately no, my script is for forms. It is possible for layouts, but Microsoft didn't provide an easy override for it like PreSaveAction. Best article I know for information on it is bernado-nguyen-hoan.com/2017/04/16/…. – Joe McShea Jun 10 at 20:26
  • but is there a simpler approach i can follow? writting a row javascript for example? – SharePoint TestDev Jun 10 at 21:01
1

I have done a test in my SharePoint enterprise wiki site collection and I can reproduce your issue. The only solution I could find is to remove the column validation.

For this issue, i would recommend you submit a feedback about this issue via the below link for your convenience, thanks.

https://sharepoint.uservoice.com/

It is a place for customers provide feedback about Microsoft SharePoint products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

  • ok will submit the user voice, but meanwhile are there any workaround to achieve my validation "ExpireDate>Today()" can i do it inside the page layout instead? – SharePoint TestDev Jun 8 at 1:03
0

This is to be expected and can not be avoided. You defined a rule and adding a new page will first create the page, then let you modify it. Now, creation violates the rule - hence the error.

You could try modifying the rule as follows: =OR([Created]=[Modified]; [ExpireDate]>Today())
This way you can create the page with an empty expire-date. I am afraid, though [Create]=[Modified] might be valid for a whole day...

  • now things are not very stable/consistent in sharepoint, as if i define a required site column inside the Pages library, and i create a new wiki page by adding its name only, then the page will be created although there is a missing required field, so i thought this will also happen if i add a list validation, that the wiki page will get created even if the list validation fail!!.. – SharePoint TestDev Jun 13 at 17:30
  • now returning back to my question, to allow the wiki page to get created, i added a default value for the expiry date field to be Today()+7, this allowed me to create a wiki page, but if the user clear the default value and try to save the wiki pages or the user enter an expiry date less than today, then the user will get a popup mentioned that list date validation failed, without showing the user-friendly error message defined inside the list validation which will be so confusing for the users.. – SharePoint TestDev Jun 13 at 17:33

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.