API
Version 7.x > API > How to create document of custom type? View modes: 
User avatar
Member
Member
poplooukhin-gmail - 1/9/2014 5:19:56 PM
   
How to create document of custom type?
Hi, all

I created a new custom document type with name custom.AuditResultType.
This document type contains following fields:
- Id
- DisplayName
- ProgramId

I want to know how can I create a new document of custom.AuditResultType using REST API or Kentico DLL API?

Best regards.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/9/2014 7:08:01 PM
   
RE:How to create document of custom type?
If you look in your install you can see examples in the /CMSApiExamples directory. Here is a snippet which creates a new "Menu Item" in the /Api-Example node of the content tree.
private bool CreateDocument()
{
// Create an instance of the Tree provider first
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

// Get the parent node - the API Example folder
TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", "en-us");

if (parentNode != null)
{
// Create a new instance of the Tree node
TreeNode newNode = TreeNode.New("CMS.MenuItem", tree);

// Set the document's properties
newNode.DocumentName = "My new document";
newNode.DocumentCulture = "en-us";

// Insert the document into the content tree
newNode.Insert(parentNode);

return true;
}

return false;
}

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/10/2014 2:31:23 AM
   
RE:How to create document of custom type?
Hi,

to addition to the above API, you can find REST examples in this documentation.

Best regards,
Juraj Ondrus