Kentico API (Creating Custom Forms)

Patrick Thompson asked on April 5, 2023 16:37

Is there a way to create Custom forms through the Kentico api by any chance? There is no api example for This. Just curious to see if someone else has done this or has discovered this functionality through the API.

The Scenario, currently going through site migrations. Created a custom tool to Import content over from Kentico 8 to the new MVC build. Looking for an easy was to do the same with Custom forms and not manually create each one by hand. I have 1000's of custom forms a crossed multiple older Kentico sites.


Recent Answers

Juraj Ondrus answered on April 6, 2023 06:32

What do you mean by custom forms? Do you mean like the online forms? If yes, do you want to create the actual records or the form object itself? If you want to create the form object itself, it is an object with its class in the CMS_Class table. And for this you need to use the methods from DataClassInfoProvider class to set the class info.

0 votesVote for this answer Mark as a Correct answer

Patrick Thompson answered on April 6, 2023 22:23 (last edited on April 6, 2023 22:24)

Thanks Juraj for the response Yes, I meant Online forms. Essentially Im looking to do both. Re-create the old form in code using and import the data from the old online form to the newly created Form. Thats good to know about the class table. I know you can create a Page based on Class Type. which I am currently already doing to create content pages with having the parent Page Object and set custom page type fields if needed:

TreeNode newPage = TreeNode.New("Page Class Type / Name");
newPage.DocumentName = "Some Page Name";
newPage.SetValue("Summary", "some content");

Im looking to do the samething but with Online Forms. I noticed in the Class Table when creating a new online form in the admin section. it will create the form and insert the class name reference in the Class Table.

Currently I have scaffolded the old Kentico Sites database in into entityframeworkcore. I can grab any data needed from the old site. I'm Just looking for a way to create new online forms within code like how you can create Tree Objects (Shown Above)

Is this what i am Looking for, To Create a new online form???

DataClassInfo newForm = new DataClassInfo();
newForm.ClassName = "Form Name";
newForm.ClassIsForm = true;
newForm.ClassFormDefinition = "";
newForm.ClassFormLayout = "";
newForm.ClassFormLayoutType = LayoutTypeEnum.Html;

DataClassInfoProvider newProvider = new DataClassInfoProvider();

// Insert or Update


0 votesVote for this answer Mark as a Correct answer

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