Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Bizfrom - dynamicly change NOTIFICATION-EMAIL?? View modes: 
User avatar
Member
Member
eagleag - 8/29/2010 3:22:44 AM
   
Bizfrom - dynamicly change NOTIFICATION-EMAIL??
general description what im trying to do:
programaticly change bizfrom notification-email and then send form to that email.

details:
I’m using a bizform that has ajax cascadingdropdows that are populated using a webservice and a few regular bizfrom inputs.
When user fills out the form and click submit I would like this to happen:
1. before creating/inserting the bizform, add the values from dropdowns to the insert.
2. once bizfrom is inserted/created, change the notification-email depending on values selected in dropdowns.
3. send the form using selected notification email

Thanks :)

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/29/2010 10:30:39 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
Hi,

You will need to modify the bizform web part and send appropriate e-mail according to your needs. In the link is general information about how to change all default web parts and in the code example is used the bizform web part and how to send e-mail in appropriate event of the web part life cycle. I hope it will help.

Best regards,
Juraj Ondrus

User avatar
Member
Member
eagleag - 8/30/2010 5:18:10 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
Hi,
I got it working and bizfrom is sending to any email address that i want. thanks :)

only issue i have now is, the order of the fields that are sent in email is'nt the order that the fields appear in cmsdesk ->tools -> bizform -> ( actuall bizfrom) -> fields

example:
in DataClass formRecord the order of fields from bizfrom is:
- ColumnNames {string[15]} string[]
[0] "MaintenenceRequestID" string
[1] "FormInserted" string
[2] "FormUpdated" string
[3] "Name" string
[4] "Phone" string
[5] "Email" string
[6] "Apartment" string
[7] "emailRecipient" string
[8] "state" string
[9] "city" string
[10] "neighborhood" string
[11] "building" string
[12] "Suggestions" string
[13] "emailSubject" string
[14] "emailFrom" string

this is code that builds email:

// Get all bizform data
GeneralConnection genConn = ConnectionHelper.GetConnection();
DataSet ds = genConn.ExecuteQuery(dci.ClassName + ".selectall", null, null, null);
if (!DataHelper.DataSourceIsEmpty(ds))
{
// Get ID of the first record -- NEED TO GET ID ON NEW ITEM
int formRecordID = viewBiz.ItemID;//ValidationHelper.GetInteger(ds.Tables[0].Rows[0][0], 0);
// Get the record with ID of the first row record
DataClass formRecord = new DataClass(dci.ClassName, formRecordID, genConn);
if (!formRecord.IsEmpty())
{

// get ID of any bizfrom
formContent += formRecord.ColumnNames[0] + ": " + formRecord.DataRow.ItemArray[0] + "<br />";
int skipFields = 0;
// skip fields that shouldnt be sent in email
if (BizFormName == "SubmitSuggestions")
{ skipFields += 5; }
else
{ skipFields += 4; }

//(formRecord.ColumnsCount - 2) this gets rid of last two fields: formInserted + formUpdated
for (int i = skipFields; i <= (formRecord.ColumnsCount - 2); i++)
{
formContent += formRecord.ColumnNames + ": " + formRecord.DataRow.ItemArray + "<br />";
}
}
}
else
{
// lblInfo.Text = "No data found.";
}


I want the order to be:
User image

Thanks

User avatar
Member
Member
hi1ton - 9/1/2010 6:42:14 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
I have a few sites with business forms on m site and would like to be albe do this too, any ideas?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/2/2010 9:15:48 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
Hi,

To achieve this you will need to change the ClassXMLSchema and order the items according to your needs in CMS_Class table in record for your particular bizform.

Best regards,
Juraj Ondrus

User avatar
Member
Member
eagleag - 9/7/2010 4:09:47 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
Hi,

I've changed the order in formRecord.StructureInfo.DataClassInfo.ClassXmlSchema.

Now i need to convert/transform the xml to email content.
This is function that sends actuall email:

CMS.EmailEngine.EmailMessage msg = new CMS.EmailEngine.EmailMessage();
msg.From = emailFrom;
msg.Recipients = emailRecipient;
msg.Subject = emailSubject;
msg.Body = emailContent; // THIS IS WHERE NEED TO LOAD CONTENT FRMO XML
CMS.EmailEngine.EmailSender.SendEmail(msg);



How can I do this?

Thanks

User avatar
Member
Member
eagleag - 9/7/2010 5:07:12 AM
   
RE:Bizfrom - dynamicly change NOTIFICATION-EMAIL??
UPDATE. changing the order didn't do anything.
I think I'm missing something.

can you maybe be more specific in what needs to be done?

many thanks :)

User avatar
Member
Member
eagleag - 9/7/2010 10:50:38 AM
   
SOLVED
Hi,
I changed a few thing and this is how I got it to work.
in bizfrom -> Notification e-mail _> TO email: {%emailRecipient%}

in code:

protected void viewBiz_OnBeforeSave(){
this.viewBiz.BasicForm.DataRow["emailRecipient"] = emailRecipient;
}


and because I'musing ajax cascading dropdowns for some of the needed values:

protected void viewBiz_OnAfterSave()
{
updateAreaIfo(state, city, neighborhood);
}


updateAreaIfo() -> updates has a few setVAlues in ti:

formRecord.SetValue("state", state);


This way the form get sent using the default bizfrom method and I can design the email content using content layout.


Thanks for all you help :)