how to script assigning new datalist item
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2012 09:37 AM
I am new to Alfresco, doing a proof-of-concept actually. I've been tasked with exploring the scripting capabilities and have run into something that I cannot get working.
I have a script that is creating a new datalist item using the out-of-the-box advanced task list. I have everything working except getting someone into the assignee field. My approach has been a lot of trial and error so far with most of the things I've done, and I'm out of trials for this one. I've tried a few different ways to get the assignee set with no success. I'm sure this is something simple, and any help is greatly appreciated.
Also, is there any sort of script reference manual available?
Thank you
var testList = companyhome.childByNamePath("Sites/XXXsiteXXX/dataLists/506e9944-2785-4a48-82d8-8c42750e527c");
// note: no error checking, or seeing if dataLists in general or this particular one already exists
var testEntry = testList.createNode(null, "dl:task")
testEntry.properties["cm:title"] = document.name;
testEntry.properties["cm:description"] = document.name;
testEntry.properties["dl:ganttStartDate"] = currentDate;
testEntry.properties["dl:ganttEndDate"] = futureDate;
// THIS IS IT: testEntry.assocs["dl:taskAssignee"] = people.getPerson("joeschmoe");
testEntry.properties["dl:taskPriority"] = "High";
testEntry.properties["dl:taskStatus"] = "Not Started";
testEntry.save();
I have a script that is creating a new datalist item using the out-of-the-box advanced task list. I have everything working except getting someone into the assignee field. My approach has been a lot of trial and error so far with most of the things I've done, and I'm out of trials for this one. I've tried a few different ways to get the assignee set with no success. I'm sure this is something simple, and any help is greatly appreciated.
Also, is there any sort of script reference manual available?
Thank you
var testList = companyhome.childByNamePath("Sites/XXXsiteXXX/dataLists/506e9944-2785-4a48-82d8-8c42750e527c");
// note: no error checking, or seeing if dataLists in general or this particular one already exists
var testEntry = testList.createNode(null, "dl:task")
testEntry.properties["cm:title"] = document.name;
testEntry.properties["cm:description"] = document.name;
testEntry.properties["dl:ganttStartDate"] = currentDate;
testEntry.properties["dl:ganttEndDate"] = futureDate;
// THIS IS IT: testEntry.assocs["dl:taskAssignee"] = people.getPerson("joeschmoe");
testEntry.properties["dl:taskPriority"] = "High";
testEntry.properties["dl:taskStatus"] = "Not Started";
testEntry.save();
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2012 09:49 AM
These are good here:
http://wiki.alfresco.com/wiki/4.0_JavaScript_API
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
Also, feel free to add to the cookbook 🙂
http://wiki.alfresco.com/wiki/4.0_JavaScript_API
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook
Also, feel free to add to the cookbook 🙂
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2012 03:13 PM
Good info to have, thank you for the links.
Unfortunately, I still haven't been able to solve my original problem. Still looking for help with that one.
S
Unfortunately, I still haven't been able to solve my original problem. Still looking for help with that one.
S
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2012 02:53 PM
In case anyone else stumbles across this in the future, here's how I got it to work. This is part of a script that is run as a rule when a new document is submitted to a folder in our document library.
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
var currentDate = new Date();
var testList = companyhome.childByNamePath("Sites/sitenamegoeshere/dataLists/b2c74e68-1ccf-494e-83a6-b36049d2607a");
// note: no error checking, or seeing if dataLists or this particular datalist even exists
var testEntry = testList.createNode(null, "dl:task")
testEntry.properties["cm:title"] = document.name;
testEntry.properties["cm:description"] = document.name;
testEntry.properties["dl:ganttStartDate"] = currentDate;
testEntry.properties["dl:ganttEndDate"] = futureDate;
testEntry.properties["dl:taskPriority"] = "High";
testEntry.properties["dl:taskStatus"] = "Not Started";
testEntry.save();
testEntry.createAssociation(people.getPerson("assigneeusername"),"dl:taskAssignee");
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
var currentDate = new Date();
var testList = companyhome.childByNamePath("Sites/sitenamegoeshere/dataLists/b2c74e68-1ccf-494e-83a6-b36049d2607a");
// note: no error checking, or seeing if dataLists or this particular datalist even exists
var testEntry = testList.createNode(null, "dl:task")
testEntry.properties["cm:title"] = document.name;
testEntry.properties["cm:description"] = document.name;
testEntry.properties["dl:ganttStartDate"] = currentDate;
testEntry.properties["dl:ganttEndDate"] = futureDate;
testEntry.properties["dl:taskPriority"] = "High";
testEntry.properties["dl:taskStatus"] = "Not Started";
testEntry.save();
testEntry.createAssociation(people.getPerson("assigneeusername"),"dl:taskAssignee");