This topic is locked

VB Code Help

2/5/2007 6:55:30 PM
ASPRunnerPro General questions
D
DNuccio author

Good Evening. I have recently purchased ASPRunner Pro Version 4.01. I really must say that I really think you have an awesome application. It automatically has done 90% of my work work flow for me. I do have a beginners question that I have not yet been able to get my brain completely around yet. I have a table for pet adoption applications. On this table is a field called "ASSIGNED TO". It is a drop down linked to another table called "PASSWORDS". where it is pulling names of our staff members.
My 2 part question is,

  1. How can I send an email to the assigned person on the application once the edit page "SAVE" button is pressed. The PASSWORD table has a field called "EMAIL" that stores the email address and "USER NAME" that stores the actual name of the user.
  2. And I would like to have the Subject say: "Current Username" has assigned application "APPLICATION ! APID" to you

    with the message body of:
    Date: "now()"

    From: "Current User Name" from PASSWORD TABLE

    APID: "APID" from APPLICATION TABLE

    Name: "APPLICANT NAME" from APPLICATION TABLE

    Link: show a hyper link to the edit page for the particular APID with login & password

Sergey Kornilov admin 2/6/2007

Use BeforeEdit event and sample action Send email with new data. Modify code according to your needs.

D
DNuccio author 2/6/2007

Use BeforeEdit event and sample action Send email with new data. Modify code according to your needs.


Could you please send me a sample code for me to try and work with.

J
Jane 2/7/2007

Dana,
to get sample code for the event select Before record updated event on the left panel on the Event tab, click on the Action button and choose Send email with new data action.

D
DNuccio author 2/7/2007

I originally tried that. What I am cunfused on is how to structure it to do what I wanted.
here is the sample code:

**

Dim keys

message =""
keys = dict.keys

For n = 0 To dict.Count-1

message = message & keys(n) & " : " & dict(keys(n)) & vbcrlf

Next
email="test@test.com"

subject="New data record"
sendmail email, subject, message
**
Could you please show me how I may be able to

email="PASSWORD TABLE ! EMAIL FIELD"

subject="PASSWORD TABLE ! USER FULL NAME" & has assigned you application # & "APPLICATION TABLE ! APID"

body=" date: "now()" return

From: "PASSWORD TABLE ! USER FULLNAME"

Applicant: "APPLICATION TABLE ! FIRSTNAME FIELD" return

link: "to APID record in edit mode with login permissions of the "PASSWORD TABLE ! USERID & PWD" fields.
I am sorry for asking but I am a beginner and an example of this code would help allot.

C
clig 2/7/2007

I originally tried that. What I am cunfused on is how to structure it to do what I wanted.

here is the sample code:

**

Dim keys

message =""
keys = dict.keys

For n = 0 To dict.Count-1

message = message & keys(n) & " : " & dict(keys(n)) & vbcrlf

Next
email="test@test.com"

subject="New data record"
sendmail email, subject, message
**
Could you please show me how I may be able to

email="PASSWORD TABLE ! EMAIL FIELD"

subject="PASSWORD TABLE ! USER FULL NAME" & has assigned you application # & "APPLICATION TABLE ! APID"

body=" date: "now()" return

From: "PASSWORD TABLE ! USER FULLNAME"

Applicant: "APPLICATION TABLE ! FIRSTNAME FIELD" return

link: "to APID record in edit mode with login permissions of the "PASSWORD TABLE ! USERID & PWD" fields.
I am sorry for asking but I am a beginner and an example of this code would help allot.


Something like - Assign session vars to your dicts on Before Edit
Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
Session("UserEmail") = dict("UserEmail")

Session("Password") = dict("Password")
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case

End Function
Then in After Edit something like
Sub AfterEdit()

'** Send simple email ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
email=Session("Email")

message="A Tech Support Advisor has taken ownership of your referral. You can view and add your own actions to your referral: " & vbcrlf & "http://server.com/techsupport/ts_new_tickets/CSR_Records_list.asp?TargetPageNumber=1&action=Search&lang=&orderby=&dir=&PageSize=20&masterkey=&SearchField=Sims&SearchOption=Equals&SearchFor="; & Session("Sims")

subject="Tech Support Referral Ticket Ownership: " & Session("TSR") & " Entered: " & Session("ServiceDate") & " Project: " & Session("Project") & " sims: " & Session("Sims")

sendmail email, subject, message

End Sub