Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > BizForm - substring fiedl in autoresponder email View modes: 
User avatar
Member
Member
vjmdev - 2/2/2011 3:04:16 PM
   
BizForm - substring fiedl in autoresponder email
Hi,

I'm using BizForm and I would like to know how can i get the last 4 digits of a field in the autoresponder email.

For example

$$label:GroupNumber$$ will give the the entire field

What is the syntax to take the substring of this field?

Thanks a lot


User avatar
Member
Member
kentico_michal - 2/3/2011 9:19:41 AM
   
RE:BizForm - substring fiedl in autoresponder email
Hi,

Regrettably, it is not supported to modify values in the body of auto responder email directly. I would recommend you to disable autoresponder emails from CMS Desk. You could modify BizForm web part(~\CMSWebParts\BizForms\bizform.ascx), so that it sends email in OnAfterSave method, which is invoked when user submits new bizform record.

Please take a look at following code snippets, which ensures sending email to email address specified in Email field of the bizform and as a body of the email are used 4 last digits of Message field.

Your ~\CMSWebParts\BizForms\bizform.ascx file should look like this:


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/CMSWebParts/BizForms/bizform.ascx.cs" Inherits="CMSWebParts_BizForms_bizform" %>

<cms:BizForm ID="viewBiz" runat="server" IsLiveSite="true" />


And here is your mentioned method OnAfterSave:


protected void BizFormNew_OnAfterSave()
{
DataRow row = viewBiz.BasicForm.DataRow;
string message = row["Message"].ToString();

CMS.EmailEngine.EmailMessage email = new CMS.EmailEngine.EmailMessage();
email.Recipients = row["Email"].ToString();
email.Subject = "bizform";
email.From = "admin@admin.com";
email.Body = message.Substring(message.Length - 4);

CMS.EmailEngine.EmailSender.SendEmail(email);
}


You will need to add following code to in SetupControl() (~\CMSWebParts\BizForms\bizform.ascx.cs) method in order to register OnAfterSave method:


BizFormNew.OnAfterSave += new BizForm.OnAfterSaveEventHandler(BizFormNew_OnAfterSave);


Best regards,
Michal Legen