1

am trying to fetch reccuring events from SP calendar list in javascript,there am having one issue,when am reading the edited reccurence event in javascript then it shows the next days date in javascript whether in calendar list it shows correctly,My code is as bellow

    hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl'));
    appWebUrl = decodeURIComponent(manageQueryStringParameter('SPAppWebUrl'));
    function Retrieval() {
            var ctx = new SP.ClientContext(appWebUrl);//Get the SharePoint Context object based upon the URL
            var context = new SP.AppContextSite(ctx, hostWebUrl);
            var web = context.get_web(); //Get the Site 
            var list = web.get_lists().getByTitle(ListName); //Get the List based upon the Title
            var query = new SP.CamlQuery();
            query.ExpandRecurrence = true;
            var items = list.getItems(query);
            ctx.load(items);
            ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);
            function onQuerySucceeded() {
                retrieveItems(items);
            }
            function onQueryFailed(sender, args) {
                alert('Request failed. ' + args.get_message() +
                    '\n' + args.get_stackTrace());
            }
        }
    function retrieveItems(items) {
            var enumerator = items.getEnumerator();
            while (enumerator.moveNext()) {
                   var currentListItem = enumerator.get_current();
                    var eventDate = currentListItem.get_item('EventDate');
                    var EventId = currentListItem.get_item('ID'); //"Id";
                    var TitleField = currentListItem.get_item('Title'); //"Title";    
                    var LocationField = currentListItem.get_item('Location'); //"Location";    
                    var RecurrenceField = currentListItem.get_item('fRecurrence'); //"fRecurrence";      
                    var EndDateField = currentListItem.get_item('EndDate'); //"EndDate";     
                    var EventTypeField = currentListItem.get_item('EventType'); //"EventType";     
                    var SeriesIdField = currentListItem.get_item('MasterSeriesItemID'); //"MasterSeriesItemID";
                    var recurrenceData = currentListItem.get_item("RecurrenceData");                   
            }
    }


this snapp will cleare what am trying say
enter image description here

1 Answer 1

1

Try fetching your date as shown below :

var dates = currentListItem.get_item('EventDate');
var eventDate = new Date(dates);

Its giving me the proper required output with right date and time.. See the screenshots for reference

Screenshot :1

enter image description here

screenshot 2 :

enter image description here You can see here.. first line where i am showing date fetched directly from list, without any modification has different time. But the second line has new Date which converts that in to exact time and date. Hope this will work for you too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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