cancel
Showing results for 
Search instead for 
Did you mean: 

how to script assigning new datalist item

spazur
Champ in-the-making
Champ in-the-making
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();
3 REPLIES 3

jnoob
Champ in-the-making
Champ in-the-making

spazur
Champ in-the-making
Champ in-the-making
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

spazur
Champ in-the-making
Champ in-the-making
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");