I am new in alfresco and I create a rule that execute a javascript file when a file arrives in a directory (My javascript it inside data dictionnary script file). However, this javascript script must send a http get request to a remote server but I can not use the alfresco remote. Can you suggest a solution? Thank you
My javascript code:
function main() {
var name = document.name;
var username = "";
var msgContent = "";
var siteName = document.siteShortName;
var firstName = person.properties.firstName;
var lastName = person.properties.lastName;
if (siteName == null) {
if (logger.isLoggingEnabled())
logger.log("Erreur");
return;
}
if (firstName != null) {
username = username + firstName + " ";
}
if (lastName != null) {
username = username + lastName;
}
msgContent = username + " a ajouté un nouvel élément de contenu " + name + " au site " + siteName;
if (logger.isLoggingEnabled()) {
logger.log(encodeURIComponent(msgContent));
}
var connector = remote.connect("gedrepportremote");
var result = connector.get("/api/sendSMS?siteName=" + encodeURIComponent(siteName) + "&msgContent="+encodeURIComponent(msgContent));
if (result.status == 200) {
return JSON.parse(result);
} else if (result.status == 403) {
} else {
return null;
}
}
main();
I have this error : "remote is not defined". I tried this HTTP Request from WebScript in Alfresco but it doesn't work for me.
The "remote" object is not availabe by default when using rule scripts. See Axel Faust answer in Call a repository webscript from a rule script
He also describes how to enable the "remote" root object...
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.