每天限制在 sharepoint 中只有 4 个条目

Restrict only 4 entries per day in share point

sharepoint 新手,我有一个带有 Date(Calender) 字段的 sharepoint 列表。我正在寻找一种方法来限制列表中每天只有 4 个条目。

示例:

Date        desc
01/01/2018  entry1
01/01/2018  entry2
01/01/2018  entry3
01/01/2018  entry4

or 

Date       start   end    desc
01/01/2018 10:00   10:15  entry1
01/01/2018 10:15   10:30  entry2
01/01/2018 10:30   10:45  entry3
01/01/2018 10:45   11:00  entry4

任何建议或线索都会有所帮助。

对于 SharePoint 2013 或在线经典视图,您可以使用 PreSaveAction

示例代码:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
    <script type="text/javascript">
    function PreSaveAction() {
        var check = false;
        var listid = _spPageContextInfo.pageListId.replace('{', '').replace('}', '');
        var today = new Date();
        var nextday = moment(today).add(1, 'days');
        today = moment(today).format("YYYY-MM-DD");
        var currentDate = today + 'T00:00:00.000Z';
        nextday = moment(nextday).format("YYYY-MM-DD");
        var nextDate = nextday + 'T00:00:00.000Z';
        var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'" + listid + "')/items?$filter=Created ge datetime'" + currentDate + "' and Created le datetime'" + nextDate + "'";
        console.log(url);
        $.ajax({
            url: url,
            type: 'GET',
            async: false,
            headers: {
                "accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose",
            },
            success: function (data, textStatus, jqXHR) {
                var count = data.d.results.length;
                if (count < 4) {
                    check = true;
                } else {
                    alert('Over Max items');
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(textStatus);
            }
        })
        return check;
    }
    </script>