I try running script file in directory /Company Home/Data Dictionary/Scripts/xxxx.js, but do not it. How I can to run a script file, for example, on create user with this code:
If i understand correctly, you want to implement and execute repo tier webscript.
I would suggest you go through these docs and understand webscript concepts:
https://docs.alfresco.com/5.2/concepts/ws-types.html
https://docs.alfresco.com/5.2/concepts/ws-reference.html
https://docs.alfresco.com/5.2/tasks/ws-hello-world-create.html
You can also refer this tutorial:
http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html
Now, coming to your script, you should be copying your webscript under "/Company Home/Data Dictionary/Web Scripts" or " Web Scripts Extensions" directory and register the webscript as documented here.
You would need a "web script description document, name ends with '.desc.xml'" as well apart from the javascript controller. If you follow the documents shared above, you will get clear idea of webscripts.
Sample code for your reference, upload these files under "/Company Home/Data Dictionary/Web Scripts Extensions" and register:
create-user.get.js function main() { if (logger.isLoggingEnabled()) { logger.log("Start create User"); } try { var testUser = people.createPerson("Sasha2", "Sasha23", "Sasha24", "sdfsdf@alfresco.com", "123", true, false); if (testUser != null) { // user account created model.message = "User account created"; } } catch(ex) { logger.log("Exception occurred: "+ex.message); model.message = "User account creation failed due to: "+ex.message; } if (logger.isLoggingEnabled()) { logger.log("End create user"); } } main(); create-user.get.desc.xml <webscript> <shortname>Create User</shortname> <description> Script to create user </description> <url>/create-user</url> <authentication>user</authentication> </webscript> create-user.get.html.ftl <html> <head> <title>Create User</title> </head> <body> <h3>Status: ${message}</h3> </body> </html>
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.