Read list of field values in BizForm custom submit handler

Andrew Campkin asked on January 30, 2017 23:43

Hi, Is there any way to programmatically read a list of submitted fields and their values on a custom submit handler? All the examples I can find assume you already know the names of the fields on submit.

  • private void FormItem_InsertAfterHandler(object sender, BizFormItemEventArgs e) { var form = e.Item; .... *

Correct Answer

Trevor Fayas answered on January 31, 2017 00:39

There may be an easier way than this, but what I've done in the past is look into the Class table.

In this case, you would use DataClassInfoProvider and get the class of "BizForm.MyFormNameHere", then parse the ClassFormDefinition (xml) into an XML doc, and select all the //field nodes. This will give you the Column Names, and types.

string MyFormName = "Contact";
DataClassInfo formInfo = DataClassInfoProvider.GetDataClass("BizForm."+MyFormName);
XmlDocument fieldDocs = formInfo.ClassFormDefinition;
foreach(XmlNode fieldNode in fieldDocs.SelectNodes("//field")) {
    string colName = fieldNode.Attributes["column"].Value; // Could be wrong on the "Value" part
    string colType = fieldNode.Attributes["columntype"].Value; // Could be wrong on the "Value" part
    object theColValue = e.Item.GetValue(colName);
}

Something like that.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.