cancel
Showing results for 
Search instead for 
Did you mean: 

calendar event .ics

macweaz
Champ in-the-making
Champ in-the-making
Hi!
I don't understand iCal event in aflresco share, i wonder why if i make a file like this

BEGIN:VCALENDAR
PRODID:-//Alfresco Software//Calendar 1.0//EN
VERSION:2.0
BEGIN:VEVENT
UID:3369ac31-591e-48d8-a4cd-0d145bb2e548
DTSTART:20090414T000000Z
DTEND:20090414T000000Z
SUMMARY:Course
DTSTAMP:20090403T120802Z
DESCRIPTION:my course
END:VEVENT
END:VCALENDAR

then I save like .ics
I don't see nothing in the Share

thank you.
8 REPLIES 8

mikeh
Star Contributor
Star Contributor
The .ics file needs to be of a specific content type:
space.createNode("filename.ics", "ia:calendarEvent")

Thanks,
Mike

macweaz
Champ in-the-making
Champ in-the-making
thank you Mike,
Evaluating Alfresco I'm trying to create an event through a javascript writing directly to a ics file, but even after creating the node and the ics informations, Alfresco Share can load my calendar.
What's wrong?
Can I find out some Javascript API to create an event?

mikeh
Star Contributor
Star Contributor
Why don't you take a look at how Share does it..?

http://localhost:8080/alfresco/service/script/org/alfresco/slingshot/calendar/event.post

Thanks,
Mike

macweaz
Champ in-the-making
Champ in-the-making
thank you very much!
luca.

kiri31
Champ in-the-making
Champ in-the-making
Hi,

I tried to do the same thing but i have a problem with my javaScript. I can create the event but the problem is to connect this event with the good calendar. I take a look on event.post and I think this instruction is the connection:

activities.postActivity("org.alfresco.calendar.event-created", siteId, "calendar", jsonUtils.toJSONString(data));

I have to give the siteId, when I use json.get("site"),but it doesn't recognize json, I also tried to remplace siteId by the name of my site but it doesn't work too. Maybe the creation of the event is not good ?

I'm a new Alfresco's user and i need your help.

Thanks.

mikeh
Star Contributor
Star Contributor
…when I use json.get("site"),but it doesn't recognize json
Make sure your .js script ends with .json.js
e.g.
myScript.post.json.js

Mike

kiri31
Champ in-the-making
Champ in-the-making
Hi,
Thanks for you answer, but unfortunately it doesn't work Smiley Sad

I renamed my script : add_event.post.json.js
I use a rule to execute this script : when I add a content in a space, this script is executed. (If you know an other method to execute a script !I will be interested Smiley Happy )

the error is :
A system error happened during the operation: Failed to execute script 'workspace://SpacesStore/8ac255e5-dc45-40e5-a284-8d485489d0db': Failed to execute script 'workspace://SpacesStore/8ac255e5-dc45-40e5-a284-8d485489d0db': ReferenceError: "json" n'est pas défini (AlfrescoScript#23)

here my script :

<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/lib/calendar.lib.js">
var siteId = null;
if (!json.isNull("Produit1"))
{
   siteId = json.get("Produit1");
//Produit1 is the name of my site
}

   var timestamp = new Date().getTime();
   var random = Math.round(Math.random() * 10000);
   var event = companyhome.createNode(timestamp + "-" + random + ".ics", "ia:calendarEvent");

   event.properties["ia:whatEvent"] = "Event";
   event.properties["ia:whereEvent"] = "Here";
   event.properties["ia:descriptionEvent"] = "An event";

   var fromDate = 200420091200;//I don't know the format
   var toDate = 200420091600;

   var from = new Date(fromDate);
   event.properties["ia:fromDate"] = from;

   var to = new Date(toDate);
   event.properties["ia:toDate"] = to;
   event.save();

   try
   {
      var pad = function (value, length)
      {
         value = String(value);
         length = parseInt(length) || 2;
         while (value.length < length)
         {
            value = "0" + value;
         }
         return value;
      };

      var isoDate = from.getFullYear() + "-" + pad(from.getMonth() + 1) + "-" + pad(from.getDate());
      var data =
      {
         title: params["what"],
         page: json.get("page") + "?date=" + isoDate
      }
      activities.postActivity("org.alfresco.calendar.event-created", siteId, "calendar", jsonUtils.toJSONString(data));
   }
   catch(e)
   {
      if (logger.isLoggingEnabled())
      {
         logger.log(e);
      }
   }

Thanks a lot !

mikeh
Star Contributor
Star Contributor
Ah, you didn't mention it was being fired from a rule before. Rules don't support encoding the parameters to json, nor do they support sites directly, so you'll have to either pass-in the site name yourself, or figure it out from by walking up the parent nodes of the content.

Either way, rename your webscript back to .post.js and read the parameters from the arguments as normal.

Mike