Hardik
Hardik

Reputation: 45

Alfresco javascript get custom DataList's properties

I have written one rule(execute script) on datalist, so that whenever any new item is added, it should send an email to the respective user.

In email I want to add custom properties value e.g. employee_first_name

I've tried to get datalist using

var dataLists = siteName.getContainer("dataLists"); 

But it gives an error as follows:

"getContainer" method is not available.

The script given in Alfresco javascript get custom DataList works perfectly in Javascript console.

Upvotes: 0

Views: 232

Answers (1)

Jeff Potts
Jeff Potts

Reputation: 10538

Your siteName variable is probably a string, which does not have a method called "getContainer". That's why you are seeing that message.

Here's a code snippet that fetches the data list container object given a site ID (site short name):

var siteId = "jtp-test-site-1";
var siteInfo = siteService.getSite(siteId);
var dataLists = siteInfo.getContainer("dataLists");
print(dataLists.name);

Notice the use of the built-in root-scoped object, siteService, that fetches the site info for a given site.

You can run that in the JavaScript Console and it will output the name of that folder, which is "datalists".

Upvotes: 2

Related Questions