cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduling JavaScripts

davix
Champ in-the-making
Champ in-the-making
Hi,

I was looking at Scheduling Actions in Alfresco here.
http://wiki.alfresco.com/wiki/Scheduled_Actions

It's mentioned that a scheduled action is made up of three parts, (1)a cron expression (2) a query template and (3) action template.
Is it mandatory to specify all three? Can I just mention (1)cron expression and (2)action template?

And I was going through the example here
http://wiki.alfresco.com/wiki/Scheduled_Actions#Script_Action_Example
there are lots of properties that are being set. Again, are all of them mandatory?

Please let me know, thanks!
5 REPLIES 5

loftux
Star Contributor
Star Contributor
Here is a complete example of what you need
   <!– Run a job daily at 8.30 to send out an email about expiring agreements –>    <bean id="scheduledExpringAgreements" class="org.springframework.scheduling.quartz.JobDetailBean">        <property name="jobClass">            <value>org.alfresco.repo.jscript.ExecuteScriptJob</value>        </property>        <property name="jobDataAsMap">            <map>                <entry key="scriptLocation">                    <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">                     <constructor-arg>                        <value>alfresco/module/demo/context/scripts/scheduledExpiringAgreements.js</value>                     </constructor-arg>                  </bean>                </entry>                <entry key="scriptService">                    <ref bean="ScriptService"/>                </entry>                <entry key="authenticationComponent">                   <ref bean="authenticationComponent"/>                </entry>            </map>        </property>    </bean>        <bean id="scheduledExpiringAgreementsTrigger" class="org.alfresco.util.CronTriggerBean">        <property name="jobDetail">            <ref bean="scheduledExpringAgreements" />        </property>        <property name="scheduler">            <ref bean="schedulerFactory" />        </property>        <property name="cronExpression">            <value>0 30 8 * * ?</value>        </property>    </bean>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

davix
Champ in-the-making
Champ in-the-making
Thanks! Works like a charm. Smiley Happy

jrott
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to do the same, schedule a script and send a mail to users. Is there a way to inject the root scoped objects in the script ? Like companyhome, userhome… ?

Thanks

davix
Champ in-the-making
Champ in-the-making
Yes, it's possible. Take a look at this –> http://wiki.alfresco.com/wiki/3.4_JavaScript_API#Root_Scope_Objects

you could write something like this–
var name = userhome.properties.name‍
to get the userhome

ltardioli
Champ in-the-making
Champ in-the-making
Loftux, where I put this code?
Scheduled-Action-Services-Context.xml in shared/classes/alfresco/extensions ?

Thanks!