Hi..
I am working with Folder Rules. I want a POST method to be executed when a file is created in the folder. I upload the JS file to the SCRIPT directory. I have everything configured. This is the content of my file
function traer(){
var user = "Luis";
var name ="Diaz";
//alert("Nombre: " + user + " Apellido: " + name);
$.ajax({
type: "POST",
url: "http://localhost/alfresco/index.php/wp-json/gf/v2/workflow/webhooks/10/Fytn4QUNj9XWrzcvRzAPG79CB",
data:{Nombre:user, Apellido:name},
success: function(data)
{
alert ("Muy bien");
}
});
} // Cierra de la funcion TRAER
traer();
This works fine in my custom code but in Alfresco it doesn't work for me.
This is my error
20 KB (Error: Failed to execute script 'workspace://SpacesStore/f2d8d60b-6bcd-425e-9b5c-6927b42d44f3': 04130025 ReferenceError: "jQuery" is not defined. (workspace://SpacesStore/f2d8d60b-6bcd-425e-9b5c-6927b42d44f3#6)) |
It does not detect the Jquery tag nor $ .Ajax
Hi,
We can call ajax from client side javascript and javascript which you are using rule , it is server side script so you can not call ajax.
There is another way where you can call java method from script and from java code you can call external service.
Please refer below thread.
Hi,
Which type of example you want me to provide?
Thank you very much for you helping
An example of how to execute a POST method on a folder rule. From the beginning I thought that this custom code would work for me
function traer(){
var user = "Luis";
var name ="Diaz";
alert("Nombre: " + user + " Apellido: " + name);
$.ajax({
type: "POST",
url: "http://localhost/alfresco/index.php/wp-json/gf/v2/workflow/webhooks/10/Fytn4QUNj9XWrzcvRzAPG79CB",
data:{Nombre:user, Apellido:name},
success: function(data)
{
alert ("Muy bien");
}
});
} // Cierra de la funcion TRAER
traer();
But the reality is that it is not as simple as it sounds. I would like an example of how to do a POST method step by step from a folder rule.
Thank you
Hi, Rulescript is server side script so you can not call ajax from that.
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.