Automatic email to several people

Hi.

I need to know how I can create an automatic email routine for my internal receipients in my application.

  • I have a complaint database with one main form.

  • This form has 6 steps in its workflow. All these steps are named.

  • I have a hidden view with 2 columns. The named step is in the first column and the receipients in the other.

  • In this view all receipients are separated by commas.

When I test my application I use the following code:

TempVar1 := @GetField(“GRP”);

FIELD Adresser := @DbLookup(“”:“NoCache”;“”:“QSYS.NSF”;“TestView”;TempVar1;“RCP”);

@Command([RefreshWindow])

The returned value seems to be ok, but there is no commas to separate the receipients. I assume that I can put this returned value directly into my code (message.sendTo=usr) when the returned value is commaseparated.

With message

.Form = frm

.~_ViewIcon = Visual

.SendTo = usr

.Subject = sbj

.Principal = “Quality System”

Call .Send(True)

End With

In my existing code I have hardcoded the people I want to inform by this email, but now I need to do the code more flexible.

I use my own message forms with doclinks to the complaint form. Each message form has different text and background color. I don’t want to use the standard memo as message form.

Can anyone help me?

Subject: Automatic email to several people

In LS when you set the SendTo field it must be a text list. If the group field that you are trying to send to is a string the email will not be sent to everyone in the list. If it is a string you could turn it into a LS array by simply doing something like this:

SendTo = ArrayUnique(FullTrim(Split(doc.GroupField(0),“,”)))

The Split, FullTrim and ArrayUnique functions are new with R6. Split turns a string into an array, FullTrim works like @trim() and removes null entries, and ArrayUnque works like @unique…

hth,

Wendall Mosemann

Subject: RE: Automatic email to several people

Thank you for your information but I get a “Type mismatch” meesage when I try to use it in mey test.

This code gives me the string:

teststr = (uidoc.fieldgettext(“Adresser”))

but this give me the error:

testvalue = Arrayunique(Fulltrim(Split (uidoc.FieldGetText(“Adresser”)," ")))

I also have a question about the spaces. The returned value is based on a names field and these data is presented like this:

CN=Fname1 Lname1/O=xxxx CN=Fname2 Lname2/O=xxxx CN=Fname3 Lname3/O=xxxx

Because of this I have spaces between Fname and Lname + between the receipients.

Any ideas to solve this?

Subject: RE: Automatic email to several people

teststr = (uidoc.fieldgettext(“Adresser”))

So the name values in your teststr variable are separated by a plus (+) sign?

ex.)teststr would contain: “John Doe/org+Jane Smith/org+Fname_n Lname_n/OU”

You’d want to change the split function to split on your + seperator.

testvalue = Arrayunique(Fulltrim(Split (teststr,“+”)))

That should give you an array of:

testvalue(0)=“John Doe/org”

testvalue(1)=“Jane Smith/org”

testvalue(n)=“Fname_x Lname_x/OU”

hth,

Wendall

Subject: RE: Automatic email to several people

No.

In the field on the form the names are separated by comma.

When I display the field in the view the names also are separated by commas but the CN= and the O= are also displayed.

When I get the values by using @DbColumn the commas have disappeared. If I then shall split I have to use “space” but this is wrong because there also is spaces between Fname and Lname.

I just posted another question about this.

Subject: RE: Automatic email to several people

You may need to change the lookup to put it in the format you want. An @DbLookup will return an array. Since you really want a string in LS you should probably turn the array into a string. To do that you’d need to wrap @Implode around it.

FIELD Adresser := @implode(@DbLookup(“”:“NoCache”;“”:“QSYS.NSF”;“TestView”;TempVar1;“RCP”);“+”)

If you only want the common name for the person you could also format the name in that format by using @name. (or as a side note - use the @name formula in the view you are looking up against to convert to common name).

FIELD Adresser := @implode(@name([CN];@DbLookup(“”:“NoCache”;“”:“QSYS.NSF”;“TestView”;TempVar1;“RCP”));“+”)