Version

List.addDocument

This method is used to create a new document in a Document Library. 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 library within a site and tries to add a document, SharePlus can get the site URL, the library GUID, and the content type.

You can use List.addDocument in two different ways:

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

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

Syntax

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

List.addDocument Parameters

Parameter

Type

Description

args

JavaScript Object

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

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.