API
Version 7.x > API > v7 BizForm code View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 10/10/2012 6:18:34 PM
   
v7 BizForm code
I ported some simple v6 BizForm code over to a new v7 project and have run in to an issue. The code is virtually the same as here: http://devnet.kentico.com/docs/7_0/devguide/index.html?api_bizforms_creating_a_new_record.htm

The error is that this line is now deprecated:
BizFormItem formRecord = new BizFormItem(dci.ClassName, bProvider);

The constructor now does not take any parameters. There is a warning but it allows compilation:
warning CS0618: 'CMS.FormEngine.BizFormItem.BizFormItem()' is obsolete: 'This constructor is meant for system purposes, it shouldn't be used directly.'

I can set bProvider later but the 2 ClassName type fields are read only.

When I try to call:

formRecord.SetValue(fieldName,'fieldValue');

I get 'Object reference not set to an instance of an object.' which I assume is because there is no actual BizForm set for the new record so the check against the fieldname breaks.

I am running v7 unpatched. I ran through the doco for the fixes in KIM for 7.0.1 and 7.0.2 and there is no mention of a BizForm fix there.

Am I missing something simple?

User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 10/10/2012 6:44:10 PM
   
RE:v7 BizForm code
After further tinkering I found the 'New' static method for the BizFormItem class.

BizFormItem formRecord = BizFormItem.New(dci.ClassName, bProvider);

Is there a better way to do it?

In the very least the doco needs to be updated :)

If I qualify for a new tree pls put BenGriffo on the plaque ;)

User avatar
Member
Member
davids-kentico - 10/11/2012 3:28:45 AM
   
RE:v7 BizForm code
Hey,

this is the best way to do it. Using the static method instead of the contructor makes sure that the instance is created correctly even if the class is customized in some way.

You can find a similar analogy in the CMS.IO class - http://devnet.kentico.com/docs/devguide/index.html?filesystemapi_using_cms_io.htm

I will make sure the documentation gets updated.

Whether or not you are eligible for a tree, that I don't know, I'll ask around.

Thanks for letting us know about the bug.

User avatar
Member
Member
davids-kentico - 10/11/2012 4:46:40 AM
   
RE:v7 BizForm code
Hey, it's me again.

Sorry, no trees for documentation bugs, I've been told...

User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 10/11/2012 6:13:06 AM
   
RE:v7 BizForm code
Ahah no worries, was wishful thinking ;)

Hopefully my post helped some others out making the move to v7.

Cheers from Oz