Greetings guys.
I want to execute a "POST" method when creating a file in an Alfresco folder. I need to send Alfresco data for a web page. In folder rules I have an option to call a JavaScript function. I thought about doing a POST method with Jquery but it doesn't work for me because it blocks it in Backend. So I am very confused. I can't find a way to do it. The only option I have in the folder rules is JavaScript, so with JavaScript they should call another function in Java maybe?
Can you elaborate little bit, what you want to achieve?
From what i can understand, you have a folder in repository where there is folder rule when gets fired on content upload. And you want to use a http post call from within rules on event of content upload, right?
It's correct
I share some images with you.
From a JavaScript code execute a POST method that sends data to a website made in WordPress. I thought it could be done like this. At first I created a POST method with AJAX but it didn't work.
So I'm very confused on how I could do this.
Thank you
Instead of making this complex and getting more control over the flow, i would suggest to go with the a custom behavior approach which can listen to node creation event and on create node event it can gather the required info and pass it on to third party system via http post call. You can add validation/check for the specific parent folder node as well if required
Implementing behvaior : https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html#implem...
Here you can find an example of behvaior which listens to node creation event (NodeServicePolicies.OnCreateNodePolicy): https://github.com/jpotts/alfresco-developer-series/blob/master/behaviors/behavior-tutorial/behavior...
A similar example can be found here as well: https://github.com/jpotts/alfresco-kafka/blob/master/alfresco-kafka-repo/src/main/java/com/metaversa...
your implementation could be something like;
public class CreateObjectBehaviour implements NodeServicePolicies.OnCreateNodePolicy, InitializingBean { private final NodeService nodeService; private final PolicyComponent policyComponent; public CreateObjectBehaviour(final ServiceRegistry serviceRegistry, final PolicyComponent policyComponent) { this.nodeService = serviceRegistry.getNodeService(); this.policyComponent = policyComponent; } @Override public void afterPropertiesSet() { //You can bind on custom types as well based on your requirement. policyComponent.bindClassBehaviour(NodeServicePolicies.OnCreateNodePolicy.QNAME, ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT)); } @Override public void onCreateNode(final ChildAssociationRef childAssocRef) { final NodeRef createdNode = childAssocRef.getChildRef(); if (nodeService.exists(createdNode)) { //TODO:: //Get the information from created node //Prepare the post call payload as needed //Send post request } } }
Hello @viperboys ,
Did you manage to do it at the end? I'm stuck in the same place, I could really use some help.
Thank you.
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.