<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is there a way to create a calendar event using javascript? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/is-there-a-way-to-create-a-calendar-event-using-javascript/m-p/81428#M25107</link>
    <description>&lt;P&gt;Used your code with small change and its working.&lt;/P&gt;&lt;PRE&gt;var node = companyhome.childByNamePath("Sites/demo/calendar"); 
var myEvent = node.createNode(new Date().getTime() + "-" + Math.round(Math.random()*10000) + ".ics", "ia:calendarEvent")
myEvent.properties["ia:whereEvent"] = "Where event";
myEvent.properties["ia:descriptionEvent"] = "This is the description";
myEvent.properties["ia:whatEvent"] = "What event";


var fromDate = new Date();
var fromISODate = utils.toISO8601(fromDate);
myEvent.properties["ia:fromDate"] = fromISODate;

var toDate = new Date();
toDate.setHours(toDate.getHours() + 3);
var toISODate = utils.toISO8601(toDate);
myEvent.properties["ia:toDate"] = toISODate;


myEvent.save();
logger.warn("Created new calendar event: " + myEvent.nodeRef);&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Oct 2020 08:44:47 GMT</pubDate>
    <dc:creator>sp2</dc:creator>
    <dc:date>2020-10-21T08:44:47Z</dc:date>
    <item>
      <title>Is there a way to create a calendar event using javascript?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/is-there-a-way-to-create-a-calendar-event-using-javascript/m-p/81427#M25106</link>
      <description>&lt;P&gt;Is there a way to create a calendar event using javascript?&lt;/P&gt;&lt;P&gt;I have a folder rule to execute a javascript that I would like to create an event in the site's calendar.&lt;/P&gt;&lt;P&gt;I am using code that is similar to what I used to create datalist items and it seems to create the item but the item does not look right when I compare it to an item that I create through the UI&lt;/P&gt;&lt;P&gt;I use the childByNamePath() to get the site Calendar "siteCalendar". The item gets created but the primary path ends with something like this "&lt;SPAN&gt;cm:_x0037_3b5d28b-48ad-45e3-8f5c-a2c6eb0405df" rather than an ics name like "1594842338500-5440ics"&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;var myEvent = siteCalendar.createNode(null, "ia:calendarEvent")
myEvent.properties["ia:whereEvent"] = "Where event";
myEvent.properties["ia:descriptionEvent"] = "This is the description";

var fromDate = new Date();
var fromISODate = utils.toISO8601(fromDate);
myEvent.properties["ia:fromDate"] = fromISODate;

var toDate = new Date();
toDate.setHours(toDate.getHours() + 1);
var toISODate = utils.toISO8601(toDate);
myEvent.properties["ia:toDate"] = toISODate;

myEvent.properties["ia:whatEvent"] = "What event";


myEvent.save();
logger.warn("Created new calendar event: " + myEvent.nodeRef);&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:24:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/is-there-a-way-to-create-a-calendar-event-using-javascript/m-p/81427#M25106</guid>
      <dc:creator>Scorpios</dc:creator>
      <dc:date>2020-07-15T20:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to create a calendar event using javascript?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/is-there-a-way-to-create-a-calendar-event-using-javascript/m-p/81428#M25107</link>
      <description>&lt;P&gt;Used your code with small change and its working.&lt;/P&gt;&lt;PRE&gt;var node = companyhome.childByNamePath("Sites/demo/calendar"); 
var myEvent = node.createNode(new Date().getTime() + "-" + Math.round(Math.random()*10000) + ".ics", "ia:calendarEvent")
myEvent.properties["ia:whereEvent"] = "Where event";
myEvent.properties["ia:descriptionEvent"] = "This is the description";
myEvent.properties["ia:whatEvent"] = "What event";


var fromDate = new Date();
var fromISODate = utils.toISO8601(fromDate);
myEvent.properties["ia:fromDate"] = fromISODate;

var toDate = new Date();
toDate.setHours(toDate.getHours() + 3);
var toISODate = utils.toISO8601(toDate);
myEvent.properties["ia:toDate"] = toISODate;


myEvent.save();
logger.warn("Created new calendar event: " + myEvent.nodeRef);&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Oct 2020 08:44:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/is-there-a-way-to-create-a-calendar-event-using-javascript/m-p/81428#M25107</guid>
      <dc:creator>sp2</dc:creator>
      <dc:date>2020-10-21T08:44:47Z</dc:date>
    </item>
  </channel>
</rss>

