Kentico 8: API Examples - Form Records

Tim Spring asked on April 22, 2014 06:56

Hi,

I'm trying to find examples of API code for form record manipulation in Kentico 8.

Particularly the Add, Update and Delete records examples as in the Kentico 7 documentation:

http://devnet.kentico.com/docs/7_0/devguide/index.html?api_bizforms_creating_a_new_record.htm

http://devnet.kentico.com/docs/7_0/devguide/index.html?api_bizforms_updating_a_record.htm

http://devnet.kentico.com/docs/7_0/devguide/index.html?api_bizforms_deleting_a_record.htm

I've tried searching the new Kentico 8 documentation and looking in the installation API example folder: /CMSAPIExamples but there doesn't seem to be any examples relating to form records.

Do any of these examples for Kentico 8 exist? Using the previous Kentico 7 code examples (as above) no longer work in Kentico 8.

Thanks, Tim

Recent Answers


Brenden Kehren answered on April 22, 2014 09:20

Hey Tim, take a look at a few of the Articles talking about API and Form changes.

http://devnet.kentico.com/articles/api-changes-in-kentico-8
http://devnet.kentico.com/articles/kentico-8-technology-form-engine-improvements

I haven't found any documentation on the API Examples either for Forms but you can also check out the API documentation here:

http://devnet.kentico.com/docs/8_0/api/?topic=html/N_CMS_OnlineForms.htm

I think the namespace you're looking for is the CMS.OnlineForms namespace vs. BizForms. Also pay attention to the Provider library, this was updated with the DataQuery library now. Take a look here:

http://devnet.kentico.com/articles/kentico-8-technology-dataquery

0 votesVote for this answer Mark as a Correct answer

Yehuda Lando answered on April 22, 2014 09:21

I didn't test this, but with a couple changes, the original example works: DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(bfi.FormClassID); BizFormItem formRecord = BizFormItem.New(dci.ClassName);

1 votesVote for this answer Mark as a Correct answer

Tim Spring answered on April 22, 2014 12:51

Thanks for the pointers. I tried Yehuda's suggestion and it made the Insert record function work in my custom code, so I hope it'll be the same for Update & Delete.

Another form API problem I'm having is you used to be able to update a fields data in a current form (for example during an OnAfterValidate event) even if the field wasn't included in the form layout/edit-form by using:

viewBiz.BasicForm.Data["fieldname"] = "newdata";

This doesn't seem to work now.

I assume I should be using:

viewBiz.SetDataValue

But there's no documentation on how to use it, only GetDataValue, which I can get to work fine. All I get when I try to use SetDataValue is the EventLog error:

CMS.FormControls.AbstractBasicForm.SetDataValue(string, object)' is inaccessible due to its protection level

I'm not sure why, I'm using it in the same section of code as the GetDataValue which works ok.

Should I be setting form field data, that's not included in the layout/edit-form another way?

Thanks, Tim

0 votesVote for this answer Mark as a Correct answer

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