Version

List.addItem

This method is used to create a new item in a SharePoint List. As parameter, it receives a JavaScript object that can include several properties. When the parameter has no properties with contextual information, this method relies on user navigation to get the context. For example, after the user navigates to a specific list within a site and tries to add an item, SharePlus can get the site URL, the listName, and the content type.

You can use List.addItem in two different ways:

  1. From a Mobile Workspace, where you need to provide contextual information like the site URL and list name. In this case you can use List.getListMetadata to get the content types and required fields from the list. In the case that you need the GUID of the list, you can get it using the Web.getWebsAndLists method.

  2. From a Custom Form defined for a list, where you already have contextual information available from the user navigation through the UI.

Syntax

SPlus.List.addItem (args, function (result){
        //TODO: Implement what to do when a new item was successfully added
}, function (eResponse){
        //TODO: Implement how to handle error information
}, function (){
        //TODO: Implement how to handle a user’s cancel
});

List.addItem Parameters

Parameter

Type

Description

args

JavaScript Object

The args Object includes a property with the attributes of the new item. And, optionally, contextual information to be used by SharePlus to find the list and add the new item.

onSuccess callback function

Parameter

Description

function (result)

Success callback function to be implemented. When successful, result returns as an empty dictionary.

onError callback function

Parameter

Description

function (eResponse)

Error callback function to be implemented, which receives the eResponse JavaScript Object.

onCancel callback function

Parameter

Description

function (result)

Cancel callback function to be implemented.