Expose SharePoint lists and document libraries as data
To expose SharePoint lists and libraries as data, you need to generate a SmartObject based on that SharePoint list or library. You can generate the SmartObject when creating your application
When you create an application from a SharePoint list or library, the product automatically creates a SmartObject for the list/library and other SmartObjects as needed, such as SmartObjects for attachments on custom Lists. This is why the Data check-box is selected and grayed out by default.
Follow these steps to generate single or multiple SharePoint list or library SmartObjects for a site:
- Click on New from either the libraries or lists section.
- A list of SharePoint lists or libraries displays depending on which section you are working from. Select the items for SmartObjects to be created for by clicking the check-box in front of each item. Select the scope of these items. The scope can be changed per item at a later stage. The scope options are:
- This Site and all of its subsites - This option enables the use of the SmartObjects in a workflow designed in the K2 for SharePoint application from any list or library in the Site Collection including all of the sites subsites.
- List/Library - This option enables the use of the SmartObjects in a workflow designed in the K2 for SharePoint application only for the specific list or library.
- None - Selecting this option will prevent the use of the SmartObjects in a workflow designed in the K2 for SharePoint application.
- Click OK to generate the selected items as SmartObjects.
- The items selected will now be listed under the relevant sections indicating the scope per item.
- If you click on New again, only the items for which SmartObjects do not exist will display. You can select them to generate SmartObjects.
When generating SmartObjects based on SharePoint lists, the associated Attachments SmartObject will also be generated and displayed in the list of SmartObjects as per the image above.
Clicking OK or Cancel on the Manage SmartObjects Landing page after generating SmartObjects, will not influence the SmartObjects generated. It will only save or cancel changes made to the Scope of these SmartObjects.
Follow these steps to enable SmartObjects for use in workflows:
- Open the K2 for SharePoint App Settings page from the SharePoint Site Contents and select the SmartObject item under Artifacts as shown in the image below
- This takes you to the Manage SmartObjects page.
- Select a SmartObject from either the Libraries or Lists section by highlighting the SmartObject
- Click on Edit. This enables the Scope drop-down which allows you to select the scope of visibility for the SmartObject in workflows. The Scope options are:
- This Site and all of its subsites - This option enables the use of SmartObjects in workflows designed any SharePoint list, library, or related subsites in the Site Collection.
- List/Library - This option enables the use of the SmartObjects in a workflow only for the specific SharePoint list or library.
- None - Selecting this option will prevent the use of the SmartObject in a workflow designed in the Application.
- Select an option and click OK to save the changes.
The Create Application page displays a warning message in the Data section if the product detects unsupported fields in the list/library.
Similarly, a warning displays in the Form section if the product supports a SharePoint field at the SmartObject level but not at the form level (Managed Metadata Fields, for example). You can still generate and use the form, but the system will not generate controls for the unsupported fields on the generated form.
For unsupported lists and libraries (for example a Data Connection Library), the product does not create a SmartObject nor the associated forms and views. For these unsupported lists and libraries, the Create Application page displays an error message and prevent you from creating any artifacts, as shown below.
For more information see Supported artifacts.
When a SharePoint library or list is exposed by the app, specific SmartObjects methods are created automatically. The methods can be used when creating rules in the Designer for forms, SmartObjects, and views. For lists and libraries that have identical data structures, you can appify the primary list or library and use those SmartObject methods to access the data in the secondary lists or libraries. See Reuse data.
The tables below provides a list of these methods and their definitions.
List Item methods | |
---|---|
Get List Items | Retrieves all the items in the current list. |
Get List Items For Lookups | Retrieves all the items in the current list. Only retrieves a single field which is specified by the field’s internal name. Used by other lists to retrieve items as fast as possible. |
Get List Item By ID | Retrieves a single item which is specified by the item’s ID. |
Get List Item By Title | Retrieves a single item which is specified by the item’s Title. |
Get List Item By Name | Retrieves a single item which is specified by the item’s Name. |
Get SharePoint Time Zone | Retrieves the Time Zone of the current SharePoint site. Mostly for internal use. |
Create List Item | Creates an item in the current list. |
Add User Or Group Permissions To List Item By ID | Add permissions to a list item |
Remove User of Group Permissions From List By ID | Remove permissions from a list item |
Stop Inheriting Permissions On List Item By ID | Stop inheriting permissions from the base list item. The list item specified will now have different permissions than all other list items |
Delete Unique Permissions From List Item By ID | Delete the unique permission on the specified list item |
Update List Item | Updates a single item which is specified by the item’s ID. |
Delete List Item | Delete a single item which is specified by the item’s ID. |
Recycle List Item | Place a single item in the Recycle Bin. The item that will be placed in the Recycle Bin is specified by the item’s ID. |
Restore List Item | Restore a item from the recycle bin. The item to restore is specified by the item’s Recycle Bin GUID. |
Copy List Item | Copy an item from the current list to a target list. The item to copy is specified by ID. The target list is specified by the list’s Relative URL |
Move List Item | Move an item from the current list to a target list. The item to copy is specified by ID. The target list is specified by the list’s Relative URL |
Copy List Item From | Copy an item from a target list to the current list. The item to copy is specified by ID. The target list is specified by the list’s Relative URL |
Move List Item From | Move an item from a target list to the current list. The item to copy is specified by ID. The target list is specified by the list’s Relative URL |
Document methods | |
---|---|
Get Documents | Retrieves all the Documents in the current library. |
Get Documents Metadata | Retrieves all the Documents in the current library without the Document’s File content (Faster call) |
Get Documents Metadata for Lookups | Retrieves all the documents in the current library. Only retrieves a single field which is specified by the field’s internal name. Used by other libraries to retrieve documents as fast as possible. |
Get Document | Get a single document with the document’s file content. The document to retrieve is specified by its Name |
Get Document Metadata | Get a single document without the document’s file content. The document to retrieve is specified by its Name |
Get Document By ID | Get Document By ID |
Get Document Metadata By ID | Get a single document without the document’s file content. The document to retrieve is specified by its ID |
Get SharePoint Time Zone | Retrieves the Time Zone of the current SharePoint site. Mostly for internal use. |
Save Document to File Location | Save a single document to a local file location. The document to save is specified by Name |
Upload Document | Upload local file to current library |
Add User Or Group Permissions To Library By ID | Add User Or Group Permissions To Library By ID |
Remove User of Group Permissions Library By ID | Remove permissions from a document |
Stop Inheriting Permissions On Library By ID | Stop inheriting permissions from the base document. The document specified will now have different permissions than all other documents |
Delete Unique Permissions From Library By ID | Delete the unique permission on the specified document |
Update Document Metadata | Update a single document’s properties. The document to update is specified by Name |
Update Document Metadata by ID | Update a single document’s properties. The document to update is specified by ID |
Delete Document | Delete a single document. The document to delete is specified by Name |
Delete Document By ID | Delete a single document. The document to delete is specified by ID |
Recycle Document | Place a single document in the Recycle Bin. The document that will be placed in the Recycle Bin is specified by its Name. |
Recycle Document By ID | Place a single document in the Recycle Bin. The document that will be placed in the Recycle Bin is specified by its ID. |
Restore Document | Restore a document from the recycle bin. The document to restore is specified by the document’s Recycle Bin Guid. |
Rename Document | Rename a single document. The document to rename is specified by its Name |
Rename Document By ID | Rename a single document. The document to rename is specified by its ID |
Check In Document | Check In a single document. The document to check in is specified by its Name |
Check In Document By ID | Check In a single document. The document to check in is specified by its ID |
Check Out Document | Check Out a single document. The document to check out is specified by its Name |
Check Out Document By ID | Check Out a single document. The document to check out is specified by its ID |
Discard Document Check Out | Discard a single document’s Check Out. Discard the changes made to a Checked Out document. The document is specified by Name |
Discard Document Checkout By ID | Discard a single document’s Check Out. Discard the changes made to a Checked Out document. The document is specified by ID |
Copy Document | Copy a document from the current library to a target library. The document to copy is specified by Name. The target library is specified by the library’s Relative URL |
Copy Document By ID | Copy a document from the current library to a target library. The document to copy is specified by ID. The target library is specified by the library’s Relative URL |
Move Document | Move a document from the current library to a target library. The document to copy is specified by Name. The target library is specified by the library’s Relative URL |
Move Document By ID | Copy a document from the current library to a target library. The document to copy is specified by ID. The target library is specified by the library’s Relative URL |
Copy Document From | Copy a document from a target library to the current library. The document to copy is specified by Name. The target library is specified by the library’s Relative URL |
Move Document From | Copy a document from a target library to the current library. The document to copy is specified by Name. The target library is specified by the library’s Relative URL |
Additional methods depending on list/library settings
Folder methods (If Folders are enabled these methods are added on the list/library SmartObject) | |
---|---|
Get Folders | Retrieves all the folders in the current list/library |
Create Folder | Create a folder in the current list/library |
Rename Folder | Rename a single folder. The folder to rename is specified by its Name |
Delete Folder | Delete a single folder. The folder to delete is specified by its Name |
Recycle Folder | Place a single folder in the Recycle Bin. The folder to place in the Recycle Bin is specified by its Name |
Restore Folder | Restore a single folder from the Recycle Bin. The folder to restore is specified by its Recycle Bin GUID |
Copy Folder | Copy a single folder and all its contents from the current list/library to a target list/library. The folder to copy is specified by its Name. The target list/library is specified by its Relative URL |
Move Folder | Move a single folder and all its contents from the current list/library to a target list/library. The folder to copy is specified by its Name. The target list/library is specified by its Relative URL |
Attachment methods (Can only be enabled on a list. If enabled an Attachment SmartObject with these methods is generated) | |
---|---|
Add Attachment | Add attachment to single list item. The item to add an attachment to is specified by ID |
Get Attachment | Get a single attachment from a specific list item. The attachment to retrieve is specified by Name. The list item to retrieve the attachment from is specified by its ID |
Get Attachments List | Retrieves all the attachments from a single list item without the attachment’s file content. The list item to retrieve attachments from is specified by its ID |
Get Attachments | Retrieves all the attachments from a single list item with the attachment’s file content. The list item to retrieve attachments from is specified by its ID |
Remove Attachment | Remove a single attachment from a specific list item. The attachment to remove is specified by Name. The list item to remove the attachment from is specified by ID |
Remove All Attachments | Remove all the attachments from a single list item. The list item to remove attachments from is specified by ID |
Document Set methods (Can only be created on libraries. If a library has a Document Set Content Type and a Document Set is created in the library an additional SmartObject is created with the following methods) | |
---|---|
Get Document Sets | Retrieve all document sets in the current library |
Create Document Set | Create a document set in the current library |
Get Document Set | Get a single document. The document to retrieve is specified by Name |
Get Document Set By ID | Get a single document. The document to retrieve is specified by ID |
Get Document in Document Set | Retrieve all the documents in a single document set. The document set to retrieve documents from is specified by Name |
Get Document in Document Set By ID | Retrieve all the documents in a single document set. The document set to retrieve documents from is specified by ID |
Update Document Set | Update a single document set’s properties. The document set to update is specified by Name |
Update Document Set By ID | Update a single document set’s properties. The document set to update is specified by ID |
Rename Document Set | Rename a single document set. The document set to rename is specified by Name |
Rename Document Set By ID | Rename a single document set. The document set to rename is specified by ID |
Delete Document Set | Delete a single document set. The document set to delete is specified by Name |
Delete Document Set By ID | Delete a single document set. The document set to delete is specified by ID |
Recycle Document Set | Place a single document and all its content in the Recycle Bin. The document set to place in the Recycle Bin is specified by Name |
Recycle Document Set By ID | Place a single document set and all its content in the Recycle Bin. The document set to place in the Recycle Bin is specified by ID |
Restore Document Set | Restore a single document set and all its content from the Recycle Bin. The document set to restore is specified by its Recycle Bin GUID |
Copy Document Set | Copy a single document set and all its content from the current library to the target library. The document set to copy is specified by Name. The target library is specified by its library Relative URL |
Copy Document Set By ID | Copy a single document set and all its content from the current library to the target library. The document set to copy is specified by ID. The target library is specified by its library Relative URL |
Move Document Set | Move a single document set and all its content from the current library to the target library. The document set to move is specified by Name. The target library is specified by its library Relative URL |
Move Document Set By ID | Move a single document set and all its content from the current library to the target library. The document set to move is specified by ID. The target library is specified by its library Relative URL |
Choice methods (If a choice field is added to the list/library a Choice SmartObject with the following methods is generated) | |
---|---|
GetFieldMetaData | Retrieves the different choices that can be selected for the field. Mostly internal use. |