AnsweredAssumed Answered

How to run a script datalist in the workflow?

Question asked by shevchun_a on Feb 23, 2016

I have datalist:

<?xml version="1.0" encoding="UTF-8"?>

<!– Definition of new Model –>

<model name="dtdlm:deliveryTicketDataListModel" xmlns="">

    <!– Optional meta-data about the model –>

    <description>Data list type to track progress of a Delivery Ticket Workflow.</description>

    <author>Mike Kay</author>


    <!– Imports are required to allow references to definitions in other models –>


        <!– Import Alfresco Dictionary Definitions –>

        <import uri="" prefix="d" />

        <!– Import Alfresco Content Domain Model Definitions –>

        <import uri="" prefix="cm" />

        <import uri="" prefix="sys" />

        <import uri="" prefix="dl" />


    <!– Introduction of new namespaces defined by this model –>


        <namespace uri="" prefix="dtdlm" />


    <!– Constraint definitions –>



        <!– Type and property definitions –>


        <type name="dtdlm:deliveryTicketDataList">

            <title>Active Delivery Ticket</title>

            <description>Delivery Ticket in Progress</description>           



                <property name="dtdlm:title">





                <property name="dtdlm:dateSubmitted">

                    <title>Current State</title>




                <property name="dtdlm:submitter">

                    <title>Submitted By</title>




                <property name="dtdlm:dateChanged">

                    <title>Last Activity</title>




                <property name="dtdlm:status">









And I have script:

/execution.setVariable("alfrescoSite", "testing");

                                    execution.setVariable("alfrescoSite", "workflow-testing");

                                    // Set unique node token based on the initiator's user name + a timestamp

                                    execution.setVariable("deliveryTicketWorkflow_nodeName", + "_" +;


                                    // Create initial data list item


                                    // Get the site name and dataLists

                                    // var site = siteService.getSite(execution.getVariable("alfrescoSite"));

                                    var dataLists = companyhome.childByNamePath("Sites/" + execution.getVariable("alfrescoSite") + "/dataLists");

                                    var site = companyhome.childByNamePath("Sites/" + execution.getVariable("alfrescoSite"));

                                    // Check for data list existence

                                    if (!dataLists) {

                                      var dataLists = site.createNode("dataLists", "cm:folder");

                                      var dataListProps = new Array(1);

                                      dataListProps["st:componentId"] = "dataLists";

                                      dataLists.addAspect("st:siteContainer", dataListProps);



                                    // Create new data list variable

                                    var deliveryTicketDataList = dataLists.childByNamePath("deliveryTicketDataList");

                                    // If the data list hasn't been created yet, create it

                                    if (!deliveryTicketDataList) {

                                      var deliveryTicketDataList = dataLists.createNode("deliveryTicketDataList","dl:dataList");

                                      // Tells Alfresco share which type of items to create

                            ["dl:dataListItemType"] = "dtdlm:deliveryTicketDataList";


                                      var deliveryTicketDataListProps = [];

                                      deliveryTicketDataListProps["cm:title"] = "Delivery Tickets: In Progress";

                                      deliveryTicketDataListProps["cm:description"] = "Delivery tickets that are in progress.";

                                      deliveryTicketDataList.addAspect("cm:titled", deliveryTicketDataListProps);


                                    var deliveryTicket = deliveryTicketDataList.childByNamePath(execution.getVariable("deliveryTicketWorkflow_nodeName"));

                                    // If node was removed, create it

                                    if (!deliveryTicket ) {

                                        var deliveryTicket = deliveryTicketDataList.createNode(execution.getVariable("deliveryTicketWorkflow_nodeName"), "dtdlm:deliveryTicketDataList");

                              ["dtdlm:title"] = execution.getVariable("bpm_workflowDescription");

                              ["dtdlm:submitter"] = + " " +;

                              ["dtdlm:dateSubmitted"] = Date().toString();

                              ["dtdlm:status"] = "Initial Submission";

                              ["dtdlm:dateChanged"] = Date().toString();



I use Alfresco 5.0.
Model I connect (perhaps incorrectly) through Repozetory / data dictionary / model / download.
The model properties make it active.

How to run a script ? For example, to some of the fields are filled by default datalist in the site and other…