Jump to content
Server Maintenance This Week. ×

Email Script


acro

This topic is 3656 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I’m trying to set up an Email Script.

There are 80 customers in a data base.

I have 2 groups to send email to:

6 specific customer names are assigned to “group A”

The other 74 customer names are assigned to “group B”

I want the script to work in the following fashion:

When in a record, if the customer name belongs to “group A”, then the “sent to:” should read “group A” after the script trigger button is clicked.

If the customer name belongs to “group B”, then the “sent to:” should read “group B” after the script trigger button is clicked.

Question: To achieve this, what would be the syntax to apply on the “Email To” Calculation?

See enclosed

post-103927-0-19136600-1398712759_thumb.

Link to comment
Share on other sites

How is it decided that the Customer belongs to Group A, or Group B? Personally, in the script I'd set a variable for the Group the Customer belongs to, then set the field explicitly after the email is sent... Like: SetVariable[$customerGroup; Value:Content::CustomerGroup] Do email sending etc SetField[Content::SentTo; $customerGroup]

Link to comment
Share on other sites

Question: To achieve this, what would be the syntax to apply on the “Email To” Calculation?

 

I am afraid this question makes no sense; the "Send Mail" To calculation needs to calculate the e-mail address of the recipient/s. Neither "group A" nor "group B" are valid e-mail addresses, and if you successfully specify one of them, your mail will not be sent.

Link to comment
Share on other sites

Ok this is what I'm using and it works for the group of 6 customer you see below:

 

If (Content::Customer= "South Miami Hospital"; "Group A"; "")
& If (Content::Customer= "Baptist Hospital of Miami"; "Group A"; "")

& If (Content::Customer= "Homestead Hospital"; "Group A"; "")
& If (Content::Customer= "Mariners Hospital"; "Group A"; "")
& If (Content::Customer= "Doctor's Hospital"; "Group A"; "")
& If (Content::Customer= "West Kendall Baptist"; "Group A"; "")

 

the problem is to do the same for the rest of the 76 customers ("Group B") without writing them all out one by one.

for example:  If (Content::Customer= "Name of customer that is not part of group A, what ever the name might be,<-- don't know how to formulate this syntax"; "Group B"; "")

and link the two segments.

No worries about how the groups are set up,...just want the script to write either "group A" or "group B", on the mail to (groups are recognized by email app itself)

Please let me know your ideas,...Thank you

Link to comment
Share on other sites

Ok this is what I'm using and it works for the group of 6 customer you see below:

 

If (Content::Customer= "South Miami Hospital"; "Group A"; "")

& If (Content::Customer= "Baptist Hospital of Miami"; "Group A"; "")

& If (Content::Customer= "Homestead Hospital"; "Group A"; "")

& If (Content::Customer= "Mariners Hospital"; "Group A"; "")

& If (Content::Customer= "Doctor's Hospital"; "Group A"; "")

& If (Content::Customer= "West Kendall Baptist"; "Group A"; "")

 

Since being in a group obviously is an attribute of a customer, the easiest solution is to add a field to the Customer table, assign the respective value ("Group A" or "Group B") to each record, then simply read from that field, i.e. use the expression Content::group.

 

As for the way to code these calculations: you would use OR instead of chaining multiple If()s …

Let (
  c = Content::Customer ;
  Case (
    c = "South Miami Hospital" or c = "Baptist Hospital of Miami" or c= "Homestead Hospital" or c = "Mariners Hospital" or c = "Doctor's Hospital" or c = "West Kendall Baptist"; "Group A" ;
    c = "..." or etc. ; "Group B"
) )

… or 'simpler' and less cluttered, test for list membership …

Let ( [
c = Content::Customer ;
aList = List ( "South Miami Hospital" ; "Baptist Hospital of Miami" ; "Homestead Hospital" ; "Mariners Hospital" ; "Doctor's Hospital" ; "West Kendall Baptist" ) ;
bList = List ( manyNames . . . )
] ;
Case ( 
  not IsEmpty ( FilterValues ( aList ; c ) ) ; "Group A" ;
  not IsEmpty ( FilterValues ( bList ; c ) ) ; "Group B"
) )

… but while all this is syntactically correct, it's not the right approach.

Link to comment
Share on other sites

"Since being in a group obviously is an attribute of a customer, the easiest solution is to add a field to the Customer table, assign the respective value ("Group A" or "Group B") to each record, then simply read from that field, i.e. use the expression Content::group."

 

Yeap,...that resolved it, simple an easy!

Thank you so much, eos and all that reply!

Link to comment
Share on other sites

This topic is 3656 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.