cancel
Showing results for 
Search instead for 
Did you mean: 

Send folder& docs: custom action email button?

raptus
Champ in-the-making
Champ in-the-making
Hello everybody,
I have a problem, I must create a custom action triggered by a button (visible on the UI) to send all folder documents (zipped) via email.
How can I do?
I have already done a script that sends email through javascript into a workflow action but I have no experience with custom actions…
Anyone has a suggestion for me please? Any help would be very appreciated.
This is the old wf-javascript:
var mail = actions.create("mail-attach");
                mail.parameters.toacc = "user1";                  
               mail.parameters.from = bpm_assignee.properties["cm:email"];
               mail.parameters.subject = "Document" ;
               for (var i = 0; i < bpm_package.children.length; i++) {
                  var doc = bpm_package.children[i];
                  var docTemplate = companyhome.childByNamePath("/Data Dictionary/Email Templates/Notify Email Templates/doc.html");
                  var args = new Array();
                    args["comment"]= "+doc_note+";
                  var result = doc.processTemplate(docTemplate, args);
                  mail.parameters.text = result;
                  mail.execute(doc);
               }

How can I translate it for a custom action?
Thankyou again
Regards,

Raptus
5 REPLIES 5

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
you need dialog to open on this action and then send zip to someone specific (like admin) or user have to specify?

raptus
Champ in-the-making
Champ in-the-making
Thankyou for answer,
User doesn't have to specify,  "user1" is the email receiver (   mail.parameters.toacc = "user1";   )

I think it's the first you said, I need to know how to create a customization to trigger an action and how to build this action to run my already done javascript code (the zipping operation can be done by script I think).

I guess this is an useful function so I believe that there are many people interested to this topic… please help!  Smiley Happy

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
ok , this "bpm_assignee" will not work.
so all your script probably is not good in alfresco explorer although it works in workflow…
what you need is:
1: where you want to put your action? ( on space for instance in details space dialog)..
2: you need to open dialog when you click on action
3: you need to zip space
4: select user to send mail to.
4: send mail and atachment with it
——————————————————
if you like i can explain you how to to each part.
—————————————————
var mail = actions.create("mail-attach");
                mail.parameters.toacc = "user1";                 
               mail.parameters.from = bpm_assignee.properties["cm:email"]; THIS IS USER THAT TASK IS ASSIGNED TO
               mail.parameters.subject = "Document" ;
               for (var i = 0; i < bpm_package.children.length; i++) {//HIRE YOU SAY: FOR EVERY DOCUMENT IN WORKFLOW ADD IT INSIDE MAIL
                  var doc = bpm_package.children;
                  var docTemplate = companyhome.childByNamePath("/Data Dictionary/Email Templates/Notify Email Templates/doc.html");
                  var args = new Array();
                    args["comment"]= "+doc_note+";
                  var result = doc.processTemplate(docTemplate, args);
                  mail.parameters.text = result;
                  mail.execute(doc);
               }
after we have established what what is, can you explain next:
do you want to send zipped space to some user or you want to send files that are in some workflow. because you have one script and other on your mind. so can you be egsact on this, where do you want to put your action on.
User doesn't have to specify, "user1" is the email receiver ( mail.parameters.toacc = "user1"; )
this is true in WFs but in alfresco browser does not work, because who is user1??  you can answer this to me, who is user1 .
—————————
let me repeat my self if I understand you well:
you want to have action on space "send by email" in alfresco browser NOT IN WORKFLOW, to click on it, in dialog you want to select user to sent to(you have to do this, because there is no way alfresco to know this), and put zipped docs hire. please confirm mi this part Smiley Happy
—————————
you also have a problem  of size of mail attach (10MB) at my company many spaces are bigger then this, also you have to calculate zips size before you allow users to click send by email( big problem) .
————————–

raptus
Champ in-the-making
Champ in-the-making
1: where you want to put your action? ( on space for instance in details space dialog)..
2: you need to open dialog when you click on action
3: you need to zip space
4: select user to send mail to.
4: send mail and atachment with it

Thankyou for answer again.
1) I'd like to put my action as a button into the web explorer UI (near "add content" component) - however if you'll help me to put it into the "more action menu" it will be great too  Smiley Very Happy

2) No, the receiver is fixed: "user1", i.e. "user1 account" saved as collaborator permissions.

3) This is a big problem, but it's not necessary now…. (I will do it when all other things will be done).

4) To select the "user1" can I use this code "mail.parameters.toacc = "user1";" ??? How can I put or translate this javascript code inside a java class?

4b) I have used the "mail-attach" plugin that worked great with workflows… just understand how to use it again in this case.

The first script you posted is my workflow action script that works just like tutorials online (jeff pots..etc.)

where do you want to put your action on.
I'd like to put this action inside the web client UI (explorer), the problem is not "where" but "how" to do this thing.

this is true in WFs but in alfresco browser does not work, because who is user1?? you can answer this to me, who is user1 .

User1 is a fixed account that has already an email address and can login into our Alfresco.

you want to have action on space "send by email" in alfresco browser NOT IN WORKFLOW, to click on it, in dialog you want to select user to sent to(you have to do this, because there is no way alfresco to know this), and put zipped docs hire. please confirm mi this part Smiley Happy

This is true but we don't need to select a user to send the email… Why can't I set that account if it's registered into Alfresco?

Thankyou,
regards

Raptus

raptus
Champ in-the-making
Champ in-the-making
Thankyou all….. but sadly noone has resolved my issue yet…. :?

I really don't understand the JAVA part of the action……I guess it's not so strange this case…. Noone has to zip content of a folder and likes to send it through email???