2

I create calendar recurring tasks with JSOM(SharePoint 2013 on-prem). It works, and I can open this item from "All Events"(not "Calendar") view.

But if opened in "Calendar" view - it gives "item does not exist". If I manually create recurring task - it opens well. But all my programmatically created items give this error:

enter image description here

What I noted - it works Ok if I copy url link and remove everything after ID=n, for example:

http://url/Lists/Calendar/DispForm.aspx?ID=25.0.2017-05-18T09:00:00Z - does not work http://url/Lists/Calendar/DispForm.aspx?ID=25 - opens succesfully

Here is code snippet:

            var context = new SP.ClientContext(_spPageContextInfo.webAbsoluteUrl);
            var web = context.get_web();
            var list = web.get_lists().getByTitle("Calendar");

            var ici = new SP.ListItemCreationInformation();
            var item = list.addItem(ici);

            // set details
            item.set_item("Title", "Bob's birthday");
            item.set_item("fRecurrence", true);
            item.set_item("EventType", 1);
            item.set_item("EventDate", '2017-05-18T09:00:00Z');
            item.set_item("EndDate", '2099-05-18T09:00:00Z');
            item.set_item("RecurrenceData", "<recurrence><rule><firstDayOfWeek>su</firstDayOfWeek><repeat><yearly yearFrequency='1' month='5' day='18' /></repeat><repeatForever>FALSE</repeatForever></rule></recurrence>");

            item.update();

            // execute query
            context.executeQueryAsync(function () {
                console.log("Calendar Birthday item successfully added.");
            }, function(sender, args) {
                console.log("Error in sharepoint jsom: " + args.get_message());
            });
0

1 Answer 1

0

Created workaround for this.

Tried to crteate items using REST but same result. So added script that removes timestamps from Calendar view:

jQuery('a[href*="DispForm.aspx"]').each(function () {

    var url = jQuery(this).attr('href');
    var urlNoTimestamp = url.slice(0, -23);

    jQuery(this).attr('onclick', 'openDialog("' + urlNoTimestamp + '")');
    jQuery(this).attr('href', 'javascript:void(0)');
    jQuery(this).removeAttr("target");
});

so

../Lists/Calendar/DispForm.aspx?ID=20.0.2017-05-17T15:00:00Z

become:

../Lists/Calendar/DispForm.aspx?ID=20

Now forms open successfully

See these threads:

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.