a!shpCopyDocumentToAppian() Function

Copies a SharePoint document, specified by the value of the path parameter, to a folder within Appian. The new document will be named according to the value provided for the appianDocumentName parameter. Only documents with extensions can be copied from SharePoint to Appian.

Syntax

a!shpCopyDocumentToAppian( scsExternalSystemKey, usePerUserCredentials, hostname, port, path, httpMethod, timeout, retries, appianFolder, appianDocumentName)

Common Parameters:

scsExternalSystemKey: (Text) The key from the Third Party Credentials admin console page that corresponds to the set of credentials that should be used to authenticate.

usePerUserCredentials: (Boolean) If true the credentials set in the Third-Party Credentials settings page by the current user running the expression will be used. If false the site-wide credential values will be used.

hostname: (Text) The scheme and hostname of the SharePoint server. For example, https://sharepoint.example.com.

port: (Number (Integer)) The port on which to connect to the SharePoint server.

path: (Text) The path portion of the REST API URL to invoke. When referring to the SharePoint REST API Reference, this parameter is the part of the URL after the <site url> or <app web url> shown in the examples.

httpMethod: (Text) The HTTP method to invoke: The HTTP method to use when invoking the REST API. Valid values: "GET", "POST", "PUT", "DELETE", "MERGE"

timeout: (Number (Integer)) The amount of time, in milliseconds, to wait when attempting to connect to the SharePoint server.

retries: (Number (Integer)) The number of times to retry a connection that fails to connect within the given timeout period.

Specific Parameters:

appianFolder: (Folder) The folder in Appian to which the SharePoint document will be copied. The user running the expression must have write access to the target Folder.

appianDocumentName: (Text) The name of the document that will be created in Appian.

Returns

Writer

This function returns a writer and must be used with the bind() function.

See also:

Examples

Copy a Document from SharePoint to a Folder in Appian

First create a rule called copyFileFromSharepoint that has a single rule input of type Text, named filename. Give it the following definition:

1
2
3
4
5
6
7
8
9
10
11
=a!shpCopyDocumentToAppian(
  scsExternalSystemKey: cons!SHAREPOINT_EXTERNAL_SYSTEM_KEY,
  usePerUserCredentials: true,
  hostname: cons!SHAREPOINT_HOSTNAME,
  port: cons!SHAREPOINT_PORT,
  timeout: cons!SHAREPOINT_TIMEOUT,
  retries: cons!SHAREPOINT_NUM_RETRIES,
  path: "/_api/web/GetFileByServerRelativeUrl('/Shared%20Documents/" & ri!filename &"')/$value",
  appianFolder: tointeger(cons!SHAREPOINT_APPIAN_FOLDER),
  appianDocumentName: ri!filename
)

Now copy and paste the expression below into the INTERFACE DEFINITION in EXPRESSION MODE, save it, then call the interface in a Tempo Report to test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
=load(
  local!download: bind(
    null,
    rule!copyFileFromSharepoint(_)
  ),
  local!sharepointFileToDownload,
  local!appianFileName,
  a!sectionLayout(
    label:"Copy file from Sharepoint to Appian",
    contents: {
      a!textField(
        label: "Sharepoint filename to download",
        instructions: "Example: test.txt",
        value: local!sharepointFileToDownload,
        saveInto: local!sharepointFileToDownload
      ),
      a!buttonLayout(
        primaryButtons: {
          a!buttonWidget(
            label: "Download",
            value: local!sharepointFileToDownload,
            saveInto: local!download
          )
        }
      )
    }
  )
)
FEEDBACK