05-13-2020 06:44 PM
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
05-14-2020 01:40 AM
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.
05-14-2020 09:23 AM
05-15-2020 03:17 AM
Hi,
Which type of example you want me to provide?
05-15-2020 09:55 AM
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
05-15-2020 10:57 PM
Hi, Rulescript is server side script so you can not call ajax from that.
Explore our Alfresco products with the links below. Use labels to filter content by product module.