Create a new Record from WebDrawer

There are many samples in the ServiceAPI documentation for creating forms to create a new Record, you can adapt any of these to work in WebDrawer if you want to add a record creation form in your WebDrawer instance.  Here is a very simple first form... 

Steps

1. Create file

In the WebDrawer install folder create a new folder, give it any name (I called mine 'My'). Inside that folder create a text file (with a CSHTML extension) with any name (I called mine 'Page.cshtml').

2. Create a Form

Paste the code below into your new file:

@{
    ViewBag.Title = "Create and Upload a Document";

    var recordTypes = this.TrimHelper.Search<RecordType>(
        BaseObjectTypes.RecordType, "usable",
        pageSize: 100, properties:new string[]{"Name"}, sortBy:new string[]{"Name"});
}

<form class="trim-form" method="post" action="~/Record" enctype="multipart/form-data" style="margin-left:20px">
    <input type="hidden" name="Continue" value="Record?q=uri:{0}" />
    <fieldset>
        <legend>Document details</legend>
        <label>Record Type:</label>
        <select name="@PropertyIds.RecordRecordType">
            @foreach (var recordType in recordTypes)
            {
                <option value="@recordType.Uri">@recordType.Name</option>
            }
        </select>
        <label>Title</label>
        <input name="@PropertyIds.RecordTitle" />
        <label>Files:</label>
        <input type="file" name="Files" multiple="multiple" />
        <button type="submit" class="btn">Submit</button>
    </fieldset>
</form>

3. Open the page

Because my folder is called 'My' and my page called 'Page.cshtml' I can open the page like this:

http://MyServer/webdrawer/my/page

Summary

Read through the ServiceAPI documentation and browse the samples for more ideas.  In essence you can create any type of RM object simply by posting a set of correctly named properties to the correct end point.

Written on January 10, 2017