close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Insert record, send email to email address not on form?

Thread began 5/11/2012 2:25 am by gary.brett434358 | Last modified 5/14/2012 7:50 am by gary.brett434358 | 1933 views | 8 replies |

gary.brett434358

Insert record, send email to email address not on form?

Hi, I have a DA created page which collects client information and assign it to a staff member which has been selected from a dynamic drop down. Is there any way I can get UE to email this staff member with the record details?

For example, from the staff member menu list, I select 'John Smith', this stores his ContactID in the table. I need UE to then email John Smith with the insert record details but his email address isnt available in session.

It does exist in the recordset ie; Name: John Smith, ContactID: 100, Email: js@sky.com so inside UE I selected that field from a recordset but its doesnt work, probably as it doesnt know which email I need? <?php echo $row_WADADynListtblAdvisor['ContactEmail']; ?>

Any ideas how I would grab the email address for the inserted record?

Thanks

Sign in to reply to this post

Ian S

When the insert behaviour is used, it creates the new unique ID in a session.

You can then use this session to filter a new recordset to select the new record.

Then use the details from the recordset to populate your UE fields.

Essentially you are on the right path, but you need to load the information into a recordset.

There are other ways around it of course, in that you could store the POST value of the email field in a session and use that. So your POST behaviour would trigger:

i) Store the POST value of the email field in a session
ii) Insert the record using the WA Insert Behaviour
iii) Use the session that stores the email address as the to address in UE.

It all depends which route you want to go down.

Personally, I would go with the creation of the recordset filtered by the new unique ID created by the insert behaviour.

Cheers
Ian

Sign in to reply to this post

gary.brett434358

Hi Ian, many thanks for your kind help. Would I be correct in doing this;

Create new recordset including ContactEmail & CaseID, filter the CaseID against the session of the insert behaviour which is tblcases_CaseID2. Then in UE choose that recordset.field as the email address?

Can t try it out on my demo machine as doesnt send mail, will try and do on live now to test!

thanks again

Gary

Sign in to reply to this post

gary.brett434358

Ok, just tried on live, I must have messed something up....again! In my recordset I have WHERE tblcases.CaseID = "tblcases_CaseID2", now when I load my page I get the following error:
Parse error: syntax error, unexpected T_STRING in D:\Domains\ghldomain.co.uk\wwwroot\4\tblcases_Insert.php on line 135

Line 135 is:

$query_rsFilter4Email = "SELECT tblcases.ContactAssignedTo, tblcontacts.ContactEmail, tblcases.CaseID FROM tblcontacts Inner Join tblcases On tblcases.ContactAssignedTo = tblcontacts.ContactID WHERE tblcases.CaseID = "tblcases_CaseID2" ORDER BY tblcases.CaseID Desc ";



I replaced the "" with '' on where clause which allows page to load but no email is sent, I also change where clause to WHERE tblcases.CaseID = $_SESSION['tblcases_CaseID2'], but that also produces page error of : Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\filter4.php on line 35

Am I writing the Where incorrectly?

Sign in to reply to this post

Ian S

Hi,

You are mixing mySQL syntax and PHP by the looks of it. Ideally you should be using parameters rather than inline PHP values however, your syntax should look something like this:

$query_rsFilter4Email = "SELECT tblcases.ContactAssignedTo, tblcontacts.ContactEmail, tblcases.CaseID FROM tblcontacts Inner Join tblcases On tblcases.ContactAssignedTo = tblcontacts.ContactID WHERE tblcases.CaseID = ".$_SESSION['tblcases_CaseID2']." ORDER BY tblcases.CaseID Desc ";

This is assuming that the session you are creating within the WA Insert behaviour is called tblcases_CaseID2.

This recordset also needs to come after the Insert behaviour so that the Session Variable exists. If you are running this on the same page as the form (i.e posting the form to itself) then you will also want to wrap this new recordset in a trigger such as the one used by the Insert Behaviour so that the recordset is only called when the form is posted.

Hope that makes sense!?

Cheers
Ian

Sign in to reply to this post

gary.brett434358

Hi Ian, thanks again, got it now. I created a Param value in the recordset usi ng the session value from the insert behaviour..

WHERE tblcases.CaseID = ParamCaseID


This seems to do the trick, thank you very much for your help..

regards

Gary

Sign in to reply to this post

Ian S

:-) You are welcome.

Glad to hear that you got it working.

Cheers
Ian

Sign in to reply to this post

gary.brett434358

Arggh, think I may have spoken to soon and its live now! For some reason the email gets sent to the last record entered in db not the current record that's stored in session value?

For example:
case 100 - John Smith
case 101 - Kate Middleton
Case 102 - $_SESSION['tblcases_CaseID2'] this is taken from the insert behaviour

When inputting case 102 it should email the user being entered and filter the case id but it emails case 101 etc?

I have the email as the last part of the process, not sure how the previous case session is being stored? If I drag the session onto the page in testing it does indeed show the caseid I am creating and not the previous, so how is it getting the previous cases email address??

EDIT *** The above is incorrect, the previous case is held in session. If I add a case, then submit I can go to other parts of the site, return to insert cases page and its held the previous records value, is it possible to kill the session value after email? I have page if anyone can help..

Any ideas more than welcome..

Thanks

Sign in to reply to this post

gary.brett434358

Sorry, attached now..

**** Edit - Hi, after h=going back and reading your post Ian I moved the code below the insert record code and appears to be ok for now!

Thanks again..

Attached Files
tblcases.zip
Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...