The CreatorCon Call for Content is officially open! Get started here.

Help with email script

Excalibur 583
Tera Contributor

Can anyone tell me why my email script is not allowing different open_by users to not be copied recipients on my notification? I believe it has to do with "if (current.opened_by && current.requested_for && current.opened_by != current.requested_for) { "

------------
Email Script:

 

function runMailScript(current, template, email, email_action, event) {

    // Check if opened_by and requested_for are different

    if (current.opened_by && current.requested_for && current.opened_by != current.requested_for) {
        var openedByUser = current.opened_by;

         // Add the opened_by user to the CC field
            email.addAddress('cc', openedByUser.email, openedByUser.getDisplayValue());
       
    }
}

runMailScript(current, template, email, email_action, event);
1 REPLY 1

bammar
Kilo Sage

i think you need to simplify this 

if (current.opened_by && current.requested_for && current.opened_by != current.requested_for)

TO THIS

if ( current.opened_by != current.requested_for)

 

I assume that from reading this -  // Check if opened_by and requested_for are different

 

Also i think in this case instead of using a mail script you can put OPENED BY and Requested for in the recipients field in the Notification and I am pretty sure if they are the same person it will send one email ( check if this works) This will avoid a script  - ALSO - if you have - send to event creator box unchecked- it wont send a notification to the creator and this will only send to a diff recipient if applicable..