Home

Run js script with cron from scheduled-jobs-context.xml

You are here

5 posts / 0 new
Last post
Run js script with cron from scheduled-jobs-context.xml [Solved]

hi,

i have a .js script that a want to run every 1 hour.
I am following this tutorial http://aboutalfresco.blogspot.com/2010/01/scheduled-actions-in-alfresco.html
I've read about Scheduled Actions and i have some questions:
1. The file scheduled-jobs-context.xml must be put in tomcat/shared/alfresco/classes/extension directory right? And from there it will do its job?
2. The js script that i want the cron to run is called "hello.get.js" and it is located in Company Home > Data Dictionary > Web Scripts > org > alfresco > test
and according to the tutorial that i`m following this should be ${selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:hello.get.js"' )} , right ?

best regards

4.2.f
Check out the file -

Check out the file - "scheduled-action-services-context.xml.sample" under tomcat\shared\classes\alfresco\extension. Rename it to scheduled-action-services-context.xml and check out for various sample jobs in it. After adding/modifying you bean definition restart the server to make the changes reflect.

Sujay Pillai
Alfresco Certified Administrator

You can discuss more about this at #alfresco channel on IRC!!!

1. Yes scheduled-jobs-context

1. Yes ,scheduled-jobs-context.xml must be put in tomcat/shared/alfresco/classes/extension folder.it will trigger the quartz job you configured in CronScheduledQueryBasedTemplateActionDefinition class.
2.If the scrip you want to run located in  Company Home > Data Dictionary > Web Scripts > org > alfresco > test you should write it like

<!--note that after alfresco 4.0,  freemarker  entries must be escaped-->
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene','PATH:"/app:company_home/app:dictionary/cm:webscripts/cm:org/cm:alfresco/cm:test/cm:hello.get.js"')\}</value>

By the way why not put your js into   Company Home > Data Dictionary > scripts

If this post was helpful, please click Yes on the Post Rating

kaynezhang, thanks

kaynezhang, thanks
i have put my js file in Company Home > Data Dictionary > scripts
but an error is rised

and here is my javacript code in file createsite.js
var sitePreset = "site-dashboard";
     var shortName = "helloworld";
     var title = "Hello World";
     var description = "The Hello World site!";
     var visibility = siteService.PUBLIC_SITE;
var myNewSite = siteService.createSite(sitePreset, shortName, title, description,   visibility);

the problem is resolved. I

the problem is resolved. I used the Script Action Example at the end of this page https://wiki.alfresco.com/wiki/Scheduled_Actions
and just changed the place and the name of the script.

Topic locked