cancel
Showing results for 
Search instead for 
Did you mean: 

scheduled action for modified date

nancyaggarwal
Champ in-the-making
Champ in-the-making
Hi All

I am using alfresco community edition 4.2c and i want to write a scheduled action for modified date. i.e i want to write a action which checks everyday for the documents which are not modified by the last six months.

Anybody who can help me with this?

Thanks
Nancy
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You run an action that simply queries for documents older than the modification date and processes them.  If it could be a large number of documents you will need to think about how you "page" through the data and do that query efficiently.    You may also want to run an action that then generates actions to run on the documents that are older than the specified date.   IIRC that's how RM's cut off works.

Hi thanks for the reply.

I have defined scheduled process that execute the action defined in xml but still my documents which are older than six months are not moving to an archive store.

It is giving ERROR [freemarker.runtime] Template processing error: "No nodes selected"

Below is my scheduled-action-services-context.xml and my javascript.

scheduled-action-services-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   
    <!–
    Define the model factory used to generate object models suitable for use with freemarker templates.
    –>
    <bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"/>
        </property>
    </bean>
   
<!– run the script–>
<bean id="runscript" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">

        <property name="transactionMode">

            <value>ISOLATED_TRANSACTIONS</value>

        </property>

        <property name="compensatingActionMode">

            <value>IGNORE</value>

        </property>

        <property name="searchService">

            <ref bean="SearchService"/>

        </property>

        <property name="templateService">

            <ref bean="TemplateService"/>

        </property>

        <property name="queryLanguage">

            <value>lucene</value>

        </property>

        <property name="stores">

            <list>

                <value>workspace://SpacesStore</value>

            </list>

        </property>    

        <property name="queryTemplate">

            <value>PATH:"/app:company_home/st:sites"</value>

        </property>

        <property name="cronExpression">

            <value>0 0/15 * * * ?</value>

        </property>

        <property name="jobName">

            <value>jobA</value>

        </property>

        <property name="jobGroup">

            <value>jobGroup</value>

        </property>

        <property name="triggerName">

            <value>triggerA</value>

        </property>

        <property name="triggerGroup">

            <value>triggerGroup</value>

        </property>

        <property name="scheduler">

            <ref bean="schedulerFactory"/>

        </property>

        <property name="actionService">

            <ref bean="ActionService"/>

        </property>

        <property name="templateActionModelFactory">

            <ref bean="templateActionModelFactory"/>

        </property>

        <property name="templateActionDefinition">

            <ref bean="moveoldfiles"/>

        </property>

        <property name="transactionService">

            <ref bean="TransactionService"/>

        </property>

        <property name="runAsUser">

            <value>System</value>

        </property>

    </bean>

<!–Execute the script–>

    <bean id="moveoldfiles" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">

        <property name="actionName">

            <value>script</value>

        </property>

        <property name="parameterTemplates">

            <map>

                <entry>

                    <key>

                        <value>script-ref</value>

                    </key>

                    <value>${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:archive.js"' )}</value>

                </entry>

            </map>

        </property>

        <property name="templateActionModelFactory">

            <ref bean="templateActionModelFactory"/>

        </property>

        <property name="dictionaryService">

            <ref bean="DictionaryService"/>

        </property>

        <property name="actionService">

            <ref bean="ActionService"/>

        </property>

        <property name="templateService">

            <ref bean="TemplateService"/>

        </property>

    </bean>
   </beans>


my javascript is something like.

function addMonths(date, months) {
  date.setMonth(date.getMonth() + months);
  return date;
}


var nodes = search.luceneSearch(PATH:"/app:company_home/st:sites/cm:cms/cm:documentLibrary"//*\" AND @cm\\:modified:[addMonths(new Date(), -6)]");

for(var dest : nodes)
dest.move(archive)

Please help me with this.

Thanks
Nancy