Skip to content Skip to sidebar Skip to footer

Alfresco Javascript Get Custom Datalist

I've created a custom datalist and put some values on it. Now I try to get data values within a script that will be triggered by a rule. So far, I've trouble to get the custom dat

Solution 1:

I hope the below script will help you to resolve your datalist issue.

varsite= siteService.getSite(document.siteShortName);
vardataListsContainer= site.getContainer("datalists");
vardataLists= dataListsContainer.getChildren();

logger.log("Data List length : " + dataLists.length);
for(var x=0;x<dataLists.length;x++)
{
    vardataList= dataLists[x]; //Get the current data list        varprops= dataList.getProperties(); //Read the data list propertiesvartitle= props["cm:title"]; //read the datalist's title property
    logger.log("Data List title : " + title);

    if (title.indexOf("<data_list_title_goes_here>") > -1){ //check whether it's the required data list or notvardataListItems= dataList.getChildren(); //get the all datalistitems
        logger.log("Total dataListItems : " + dataListItems.length +" for " + title);
        for(vary=0;y<dataListItems.length;y++) //Iterate all the datalistitems one by one
        {
            vardataListItem= dataListItems[y];
            vardataListItemProps= dataListItem.getProperties();    //Read all the properties of the current datalistitem      
            logger.log(dataListItemProps["namespace:propertyname"]); //read your custom property here
            logger.log(dataListItemProps["namespace:propertyname"]); //read your custom property here
            logger.log(dataListItemProps["namespace:propertyname"]); //read your custom property here
        }
    }       
}

Solution 2:

If you're using Server side javascript, getElementById() won't work and this is for client side javascript.

Let me try with my custom datalist and will update you. In mean time, can you please share, alfresco.log & solr.log file errors?

Post a Comment for "Alfresco Javascript Get Custom Datalist"