cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic email recipient assignment

darioruizlopez
Champ in-the-making
Champ in-the-making
Hallo to everybody.

I need to send an email to a group/s of users whenever a document enters into a folder. I have created a rule in Alfresco to do so by sending emails to fixed, predefined groups.

But the problem arises when the groups are not known at design time. In my case, the different groups are created dinamically at run time. For this reason, I cannot create a rule directly with the Alfresco client to send an email to these groups, because they do not even exist when creating the rule. For this reason, I need to assign the group dynamically. Then the question is: Is there a way to change a predefined email sending rule to change the recipient of the emails? Or, alternatively, how can I set up an email sending rule at run time with a javascript? I suppose that there is a javascript API to access these rules, but I am not able to find it.

Thank you very much
3 REPLIES 3

zaizi
Champ in-the-making
Champ in-the-making
You can create a web script which takes the group name and document as arguments (reusing the javascript from the content rule). You can then just call this webscript once look up the group name and document.

darioruizlopez
Champ in-the-making
Champ in-the-making
Thank you very much.

I do not really have a javascript for sending the emails. The emails are sent via a content rule.

Finally I have just managed to access the email sending rule by writing a script which navigates through the node tree to the rule node and its parameter nodes. Modifying the parameter node causes the rule to be updated. The problem is that, because this way of accessing the rule is not documented in Alfresco I have no warranty that I will not become inoperative with time.

darioruizlopez
Champ in-the-making
Champ in-the-making
Because I believe that this topic might be useful for other users, here is the solution that I have finally used for this topic.

As an input constraint, I have named all of my notification rules to be reassigned to start with the prefix "Notify".

This done, I have travelled through the tree node of the workspace and its children looking for those nodes which correspond to system rules which refers to actions whose name starts with "Notify". This done, I have travelled through these nodes to locate the parameter named "to_many" and changed it to my new list of recipients. But, beware! the recipients are stored as a string for a single value and as a collection for several values. After this, all that is needed is to save the affected node, and we have the proper rule with the recipients reassigned