Hi,
For a project I'm working on I need to be able to upload files to an alfresco repository along with a document Id (to be stored as a value of a custom model).
After a file is uploaded, I want to make a call to an external rest service (that I have built) that will be able to retrieve other useful bits of metadata from a database by using the document Id provided and update the node using the public rest api.
I had been hoping to create a script to call this rest service using the folder rules.
My current approach doesn't seem to be working as I get errors when trying to upload when the rule is active, which I imagine is due to the seemingly common "XMLHttpRequest is not defined" error (which I get when trying to run the script locally).
Is there a way I can achieve this via this approach?
If not, what is the best approach to take?
Script which is getting executed by rule on folder, is a server side script.So the object of XMLHttpRequest will not work in that script.
If you would like to call the rest service from that file you can follow below link for implementation of it.
java - XMLHttpRequest in Rhino? - Stack Overflow
Another approach would be to define a policy and call
The javascript executed by folder rules are not client side javascript, and this is why you can not make direct calls to rest APIs.
What you can do is to develop a custom service (java code), and then publish what you need as a Javascript root object, and then use it to call and recover the metadata you need.
You can see how it is created by reading the following blog post
A Simple Pattern for Alfresco Extensions
This will guide you on how to develop the integration, how to embed it into Alfresco, and then how to publish it to be used in the Javascript file.
Try it and let us know if you have problems trying to follow the steps.
Is there a way to do this without having access to the Alfresco code?
I am using an Alfresco instance that is running externally, but I have full access to share...
You don't need the access to "Alfresco code".
All you need is to use the Alfresco SDK to generate a project, create all the customizations you need (as described in the blog post I linked), package it and deploy into your Alfresco server.
For information about the development process, check this series of tutorials
Ok, I suppose my real question is:
Is there a way to do this in Alfresco already? - by any route, not necessarily scripting
As I don't want to patch it if I don't have to
Not that I know.
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.