Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > BizForm conditional email routing View modes: 
User avatar
Member
Member
ZachW - 8/9/2011 11:04:06 AM
   
BizForm conditional email routing
I'm trying to create a form that we had on our old site that sent an email to a manager based on what location the user chose in a field that was in the form. We had a different manager contact for each location. The BizForm would be perfect for this if we could tell it who to send the email to based on one of the form fields.

Is the best way to accomplish this to just create a custom web part or is there an easy way I could clone and modify the BizForm control to work how I want it to?

User avatar
Member
Member
kentico_michal - 8/10/2011 4:00:19 AM
   
RE:BizForm conditional email routing
Hello,

You can take advantage of handling the BizForm events (such as OnAfterSave, OnBeforeValidate etc.) and send the notification email using API. In your case, I would go for the OnAfterSave that gets invoked after the BizForm data are saved.

You can clone and customize the BizForm web part and define the OnAfterSave handler in the SetupControl method (Modifying the code of standard web parts):

viewBiz.OnAfterSave += new CMS.FormControls.BizForm.OnAfterSaveEventHandler(viewBiz_OnAfterSave);


In this handler, you can access form values using the BizForm.BasicForm.DataRow property (Bizforms customization possibilities):

void viewBiz_OnAfterSave()
{
DataRow row = viewBiz.BasicForm.DataRow;
string emailAddress = ValidationHelper.GetString(row["Email"], String.Empty);
string message = ValidationHelper.GetString(row["Message"], String.Empty);

CMS.EmailEngine.EmailMessage email = new CMS.EmailEngine.EmailMessage();
email.Recipients = "admin@admin.com";
email.Subject = "bizform";
email.From = emailAddress;
email.Body = message;
CMS.EmailEngine.EmailSender.SendEmail(email);
}



Best regards,
Michal Legen

User avatar
Member
Member
ZachW - 8/12/2011 7:52:34 AM
   
RE:BizForm conditional email routing
Thanks! I was able to set my cloned BizForm up so that it takes the Location field in the form and uses that as a parameter in a select query on my Location doc type. I simply added a field for BizFormEmail to my doc type and I could pull the emailTo address from that. This is useful for anyone who uses an Offices or Location doc type!