Progress will discontinue Telerik Platform on May 10th, 2018. Learn more

Creating Data Items

Creating Data Items

You can create either a single item by passing a plain JavaScript object or multiple records with a single service call by passing an array of objects.

Creating a Single Item

Use the data.create() method to create a new content type item. On success, the server returns the ID of the created item alongside its creation date.

var el = new Everlive('your-app-id');
var data = el.data('type-name');
data.create({ 'Author' : 'Harper Lee' },
    function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

Normally, you don't need to specify the item ID—a GUID will be generated for you. However, if you need to set a specific ID, such as when importing existing data from an external database, you can do that by simply passing it with the request. Your custom ID must meet the following conditions:

  • Must be unique inside the application
  • Must be a string
var itemWithId = {
   "Id":"008541a0-b38a-11e5-84b2-b9c8b2734ef4",
   "Author":"Sample value"
};
data.create(itemWithId);

You can update system fields such as CreatedAt and CreatedBy. However, you can set them only after doing the following:

Creating Multiple Items

If you want to create more that one item in a single call, include them in an array before passing it to the data.create() method.

var el = new Everlive('your-app-id');
var data = el.data('type-name');
var multipleData = [{ 'Author': 'Sample Text' }, { 'Author': 'Second Sample Text' }];
data.create(multipleData,
    function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

Telerik Platform verifies fields marked as unique (IsUnique) just before creating each item. It keeps creating items until it reaches a duplicate value, after which it stops executing the request and returns an error. The rest of the items are not processed.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.