Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JSOM - Scheduling a list item

$
0
0

Hello all

Currently working on a task that requires scheduling a list item using JSOM.

I did find that this can be done in server side code with the following code

using (SPSite site = new SPSite("http://serverName:1111/"))
        {
            using (SPWeb web = site.RootWeb)
            {
                SPList list=web.Lists["Doc Library"];
                SPListItem listItem = list.GetItemById(1);
                ScheduledItem scheduledItem = null;
                if (ScheduledItem.IsScheduledItem(listItem))
                {
                    scheduledItem = ScheduledItem.GetScheduledItem(listItem);
                }
                else
                {
                    throw new System.ArgumentException
                      ("SPListItem must support scheduling","listItem");
                }

                DateTime startDate = new DateTime(2011, 4, 6, 22, 50, 00);
                DateTime endDate = new DateTime(2011, 4, 6, 22, 51, 00);
                scheduledItem.StartDate = startDate;
                scheduledItem.EndDate = endDate;
                scheduledItem.ListItem.Update();
                scheduledItem.Schedule();
            }
        }

I would like to do the scheduling using JSOM in a button click.

I did a search for the js equivalent for this scheduled item and found this.

SP.Publishing.ScheduledItem

But am not sure how to use this.

Need your help on this.

Thanks in advance


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>