1

Need help for below scenario in SharePoint 2013 list:

Requirement:

There is some training which happens every month. That trainer has maximum capacity of 25 for each month.

So I have created a SharePoint List which has a field called “Month” which is a Dropdown with values like Jan, Feb, Mar and so on.

So if for a particular month, the capacity is already 25, then that month should be disabled from the “Month” Dropdown field. Say for example, Jan will be enabled in the “Month” Dropdown for 25 submissions, and once 25 forms are submitted, Jan will be disabled from the list form.

Can someone please help on how to achieve this? It’s urgent.

Thank you so much

0

On "NewForm.aspx" insert contentpane with javascript:

<script type="text/javascript">
var clientContext = null;
    var web = null;
    ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
    function Initialize()
    {
        clientContext = new SP.ClientContext.get_current();
        web = clientContext.get_web();
        var list = web.get_lists().getByTitle("enter_list_name");
        var camlQuery = new SP.CamlQuery();
        var q = "<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>";
        camlQuery.set_viewXml(q);
        this.listItems = list.getItems(camlQuery);
        clientContext.load(listItems, 'Include(Id)');
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess), 
        Function.createDelegate(this, this.onQueryFailed));
    }
    function onListItemsLoadSuccess(sender, args) {
        var count = 0;
        var count = this.listItems.get_count();
if(count >= 25)
        {
alert('the list i complete...');
window.location.href = https://redirectURL link;
    }
    }

    function onQueryFailed(sender, args) {
        alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
    }
</script>

Note that you will have to do some adjustments to the code above, to fit your specific detailes.

0

You need to use JQuery Script to hide the options in the choice column with the relevant count number.

More information:

How to disable particular item in a drop down element and counting occurrences in a Sharepoint column

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.