Search code examples
ektron

Creating new smartform data using Ektron ContentTypes


Ektron 8.0.1 SP1

I am using SmartForms and Content Types to read (and hopefully write) data. I can read data but now I am attempting to write a new record similar to the following.

ContentTypeManager<member> contentTypeManager = new ContentTypeManager<member>();
ContentType<member> newmem = new ContentType<member>();

newmem.SmartForm.details.field1 = "Chuck"; // This line throws 'Object reference not set to an instance of an object.' error
newmem.SmartForm.details.field2 = "Norris";
contentTypeManager.Update(newmem);

I get the error "Object reference not set to an instance of an object." for that first assignment line. What am I missing?

I am having trouble finding good documentation on ContentTypes for 8.0.1 now that the Ektron website has been redesigned.

Thx.


Solution

  • Thanks for clarifying, to ADD content to a folder that has a smartform assigned to it, the basic code block should get you started: (Note: the Html attribute of the content is simply the xml matched to the schema you created)

    Ektron.Cms.Framework.Content.ContentManager cmanager = new Cms.Framework.Content.ContentManager();
    Ektron.Cms.ContentData cdata = new ContentData();
    cdata.FolderId = 0;
    cdata.XmlConfiguration.Id = 0; //SMARTFORM ID HERE
    cdata.Html = "<root><field1>field1 value</field1><field2>field2 value</field2></root>";
    cmanager.Add(cdata);