i would like to attach a document when it is uploaded to alfresco. I know that there is the default notification from the workflow but for internal reason my customers ask me to attach the original document into an email. I have writen a small script but i don't manage to attach the document does somebody has a solution thanks a lot.
var mail = actions.create("mail"); var docName = document.properties["name"]; var siteShortName = document.siteShortName; //var mySite = getSite(shortName); var prop = document.properties["nodeRef"] mail.parameters.to = "MY EMAIL"; mail.parameters.subject = "Ajout de document"; mail.parameters.from = "MY EMAIL"; mail.parameters.text = "Ajout du document " + docName + "Sur le site: "+siteShortName+" Projet : "+space.name ; mail.execute(document);
So if I understand, when you remove the code above the rule doesn't recognise "document" as existing?
If this is so then I think you have a deeper problem here because "document" always exists in a rule and points to the "document" you have just created.
Are you sure that your issue is not with the template trying to use document.properties["cmublicationDate"] and failing because that does not exist (or is null)?
when i use var pdfFile = document.transformDocument("application/pdf", userhome); it creates correctly the file in the userhome. But mail.parameters.node_to_attach = pdfFile does not retrieve anything i mean there is no attachment to the email.
The document.nodeRef won't work you need to send it the object but I am baffled as to why pdfFile doesn't work. All I can say at this moment is that when I get a chance I will test it out (I'm running 4.2c) and let you know because so far as I can see, it really should work and, in principal I do the same thing regularly.