Email notification: Alerting a subset of the principals?

The Create a task assignment alert tutorial presents a method for writing an automation chain that notifies the principals (users with a given permission) on a document under some condition. But I would like to only send emails to users who have opted into email notification. For example, an office manager may be a principal, but her delegate routinely processes this type of work, so only her delegate should receive notifications.

I was considering creating a group, “People who want Email Notifications,” and taking the set-intersection of this group with the principals of the document. (In my example, the office manager and the delegate are both principals; but only the delgate is in the “Email” group.)

Is it possible, in Studio, to “filter” the set of principals using such a group? If not, do you have better suggestions for other ways to model opt-in/opt-out notifications?

0 votes

1 answers

2168 views

ANSWER



same as http://answers.nuxeo.com/questions/3049/how-to-exclude-administrator-from-documentgetusersandgroups-operation

I built up the intersection using the run script operation :

Context["mail_to_read"]) = emails of “users with a given permission” including administrators

Context["mail_administrators"]) : emails of administrators

foreach ( mail_administrator : Context["mail_administrators"]) 
{
    if( Context["mail_to_read"].indexOf(mail_administrator) >= 0 )
    {
        Context["mail_to_read"].remove(Context["mail_to_read"].indexOf(mail_administrator));
    } 
}

and Context["mail_to_read"] has been cleaned up of the administrators

0 votes



Thank you! I'll give this a try.
09/26/2012