Qdabra Forms - qRules Command Guide Every qRules command, its parameters and behavior All manuals

Chapter 8 - SharePoint

First draft. This chapter has not been reviewed yet and may contain mistakes. Please read it with that in mind, and tell us about anything that does not match what you see.

These twelve commands connect a form to SharePoint: submit the form to a form library, write its data to one or more lists and read changes back, upload attachments and pictures to a document library, delete files, create folders, look up a list's GUID, read a user's profile, and work with managed metadata (term sets). Chapter 1 explains the command syntax, dynamic parameter values and where results go; this chapter assumes you know it.

The examples use this main data source:

my:myFields
  my:Title
  my:RequestId            (attribute qRulesLastModified)
  my:FolderPath
  my:Items
    my:Item               (repeating)
      my:ItemId           (attribute qRulesLastModified)
      my:Description
      my:Amount
  my:Attachments
    my:Attachment         (repeating; file attachment with attributes qRulesFilename, qRulesLink)

8.1 SubmitToSharePoint

Submits the form's XML (or the XML of another data source) to a SharePoint form library through a library submit data connection. Use it instead of a plain Submit using a data connection action when you want to choose the folder or the overwrite behavior at run time.

Syntax

SubmitToSharePoint /dssubmit=<data connection> [/dsname=<data source>] [/url=<folder URL>] [/overwrite=true|false]
Parameter Required Description
/dssubmit Yes Name of a SharePoint library submit data connection.
/dsname No Data source whose XML is submitted. Omit for the main data source.
/url No Folder location to save to, passed to the submit connection.
/overwrite No true allows the target file to be overwritten. Default false.

Result: empty on success.

Example

SubmitToSharePoint /dssubmit=SharePoint Library Submit /overwrite=true

Submits the main data source through the connection SharePoint Library Submit, replacing an existing file of the same name.

Notes

Related: SaveToSharePoint, CreateSharePointFolder.

8.2 SubmitToSharePointList

Writes form data to one or more SharePoint lists, following a mapping file that says which form field goes to which list column. It creates new list items, updates items it created before, can upload attachments to the items, and can fill child lists from repeating groups with the parent item's ID. Use it together with RefreshSharePointListItems to read later list edits back into the form.

Syntax

SubmitToSharePointList [/mapping=<data source>] [/mappingName=<name>] [/id=<relative XPath>] [/dsname=<any value>] [/xpath=<relative XPath>] [/clear=true|false] [/submit=<data connection>]
Parameter Required Description
/mapping No Data source that holds the mapping file. Default mapping.
/mappingName No Submit only this top-level mapping (and its child mappings). Omit to submit every top-level mapping in the file. Note the mixed case.
/id No XPath of the field that holds the list item ID, relative to each mapped row. Overrides the field marked as ID in the mapping.
/dsname No Turns on attachment upload. Any non-empty value works; by convention it is the name of the list service AddAttachment connection.
/xpath No XPath of the attachment field(s), relative to each mapped row. Overrides the field marked as attachment in the mapping.
/clear No true (default) empties each attachment field after it has been uploaded.
/submit No Name of a list service data connection. Only checked for existence.
/name, /namexpath, /uniqueName, /ssappid No Accepted for compatibility; they have no effect.

Result: empty. Success is false when any list submit, attachment upload or item deletion failed.

The mapping file

The mapping file is an XML file, created with the Qdabra InfoPath to SharePoint List mapping tool and added to the template as an XML data source (named mapping unless you pass /mapping). It contains one Mappings element per list. The engine reads these parts:

Part Meaning
Mappings/@mappingName Name of the mapping, used by /mappingName and by child mappings.
Properties/Level, Properties/ParentMapping 0 for a top-level mapping. A child mapping has the parent's level plus 1 and names its parent mapping.
ListCollection The list's GUID. With @useName="true" the list is found by its @ListName instead.
SharePointListURL The site URL. All mappings in one file use the first one in the file.
RepeatingGroup XPath of the repeating rows that become list items, relative to the parent row for a child mapping. Empty means one item for the whole form.
Mapping (one per column) FormField (XPath relative to the row) and SharePointColumn (internal column name). Attributes on FormField mark the field as IsId, IsAttachment, IsRichText, IsDate, IsPerson or IsParentId.

Examples

SubmitToSharePointList
SubmitToSharePointList /mappingName=Requests /dsname=AddAttachment

The first submits every mapping in the mapping data source. The second submits only the Requests mapping and its child mappings, and also uploads the files in the field marked as attachment to the new or updated list items.

Notes

Related: RefreshSharePointListItems, GetListGuid.

8.3 RefreshSharePointListItems

Compares the list items that SubmitToSharePointList created with their current state in SharePoint, and reports or copies back what has changed since, including items that were deleted from the list. It uses the same mapping file.

Syntax

RefreshSharePointListItems [/mode=report|update] [/mapping=<data source>] [/mappingName=<name>]
Parameter Required Description
/mode No report (default) only lists the differences. update also changes the form. Any value other than update (any case) means report.
/mapping No Data source that holds the mapping file. Default mapping.
/mappingName No Refresh only this top-level mapping (and its child mappings). Omit to refresh all. Note the mixed case.
/xpathsrc No Accepted for compatibility; requires /mappingName but has no other effect.
/id, /dsname No Accepted for compatibility; they have no effect. The ID field always comes from the field marked IsId in the mapping, and the list items are read directly from SharePoint.

Result: a report, with the entries separated by ;, for example Report for mapping: Requests;Item 12 does not match;Item 15 is no longer present in SharePoint List.. Success is false if a mapping could not be refreshed; the reasons are in Error, separated by |.

Examples

RefreshSharePointListItems
RefreshSharePointListItems /mode=update /mappingName=Requests

The first reports which items changed in SharePoint. The second copies those changes into the form for the Requests mapping and its child mappings.

Notes

Related: SubmitToSharePointList.

8.4 SaveToSharePoint

Uploads the files in file attachment or picture fields to a SharePoint document library, and puts the uploaded file's name and URL on the field. Use it to keep large attachments out of the form XML.

Syntax

SaveToSharePoint /url=<library or folder URL> /xpath=<XPath> [/dsname=<data source>] [/name=<file name> | /namexpath=<relative XPath>] [/uniquename=true|false] [/overwrite=true|false] [/clear=true|false]
Parameter Required Description
/url Yes URL of the library or folder to save to. A trailing / is added if missing.
/xpath Yes The attachment or picture field(s). Every selected field is uploaded.
/dsname No Data source of the fields. Omit for the main data source.
/name No File name to use. The original extension is added if the name has none or a different one.
/namexpath No Field that holds the file name, relative to each file field. Takes precedence over /name.
/uniquename No true (default) prefixes the original file name with the date and time and an underscore. false keeps the original name. Used only when neither /name nor /namexpath is given.
/overwrite No true replaces an existing file of the same name. Default false.
/clear No true (default) empties each field after its file has been uploaded.
/async, /dsnameprog, /xpathprog, /dsnamews, /dsurl No Accepted for compatibility; they have no effect.

Result: the number of files uploaded. Success is false when no file was uploaded, for example because every field was empty.

Examples

SaveToSharePoint /url=https://contoso.sharepoint.com/sites/HR/Receipts /xpath=/my:myFields/my:Attachments/my:Attachment
SaveToSharePoint /url=https://contoso.sharepoint.com/sites/HR/Receipts /xpath=/my:myFields/my:Attachments/my:Attachment /uniquename=false /overwrite=true

The first uploads every attachment under a unique name and clears the fields. The second keeps the users' original file names and replaces files that already exist.

Notes

Related: DeleteFromSharePoint, CreateSharePointFolder, SubmitToSharePointList.

8.5 DeleteFromSharePoint

Deletes a file from SharePoint by its URL, for example a file that SaveToSharePoint uploaded earlier and the user has removed.

Syntax

DeleteFromSharePoint /url=<file URL>
Parameter Required Description
/url Yes Full URL of the file to delete.

Result: empty on success.

Example

DeleteFromSharePoint /url-xpath=/my:myFields/my:Attachments/my:Attachment[1]/@my:qRulesLink

Deletes the file whose URL SaveToSharePoint stored on the first attachment field.

Notes

Related: SaveToSharePoint.

8.6 CreateSharePointFolder

Creates a folder, or a path of nested folders, in a SharePoint library or list. Folders that already exist are reused, so it is safe to run before every save.

Syntax

CreateSharePointFolder /name=<folder path> /siteurl=<site URL> /library=<library name> [/type=folder]
CreateSharePointFolder /name=<folder path> /definitionsrc=<data source> /definitionname=<name> [/siteurl=<site URL>] [/library=<library name>]
Parameter Required Description
/name Yes Folder path relative to the library, for example 2026/October. Each missing level is created.
/siteurl Yes, unless in the definition URL of the site.
/library Yes, unless in the definition Name of the library or list.
/type No folder (default, any case).
/definitionsrc With /definitionname Data source that holds a definition file.
/definitionname With /definitionsrc Name of the definition to use (not case-sensitive).
/contenttype, /contenttypeisid, /webservice No Accepted for compatibility; they have no effect.

Result: empty on success.

Examples

CreateSharePointFolder /siteurl=https://contoso.sharepoint.com/sites/HR /library=Receipts /name=2026/October
CreateSharePointFolder /siteurl=https://contoso.sharepoint.com/sites/HR /library=Receipts /name-xpath=/my:myFields/my:FolderPath

The first creates 2026 (if needed) and October inside it. The second takes the path from a field.

A definition file lets several commands share the site and library. Add it as an XML data source; parameters given in the command override its values:

<Definitions>
  <Definition name="Receipts" type="Folder">
    <Properties siteUrl="https://contoso.sharepoint.com/sites/HR" library="Receipts" />
  </Definition>
</Definitions>
CreateSharePointFolder /definitionsrc=FolderDefinitions /definitionname=Receipts /name-xpath=/my:myFields/my:FolderPath

Notes

Related: SaveToSharePoint, SubmitToSharePoint.

8.7 GetListGuid

Returns the GUID of a SharePoint list from its name. Use it when a connection or command needs the list ID and you only know the list title.

Syntax

GetListGuid /listname=<list name> /siteurl=<site URL> | /dsname=<data connection>
Parameter Required Description
/listname Yes Name of the list.
/siteurl One of the two URL of the site that contains the list. Takes precedence over /dsname.
/dsname One of the two A data connection to the SharePoint Lists web service. The site URL is its URL without _vti_bin/Lists.asmx.

Result: the list's GUID.

Examples

GetListGuid /siteurl=https://contoso.sharepoint.com/sites/HR /listname=Leave Requests
GetListGuid /dsname=GetListItems /listname=Leave Requests

Notes

Related: SubmitToSharePointList.

8.8 GetUserProfileByName

Reads a user's profile from SharePoint and puts it into a GetUserProfileByName SOAP data connection, as a list of name/value pairs. Use it to pre-fill the requester's name, e-mail or department, or to find the user's manager. FormsDesigner User Manual, Chapter 6 walks through the designer side.

Syntax

GetUserProfileByName [/dsname=<data source>] [/user=<account name>] [/source=default|siteusers|profiles] [/properties=<name>;<name>...]
Parameter Required Description
/dsname No The data source to fill. Default GetUserProfileByName.
/user No Account name of the user. Default: the current user. Required when the current user is unknown, for example in anonymous forms.
/source No siteusers reads the site's user list (works on any site without extra permissions). profiles reads the user profile store (needs extra app permission). default (default) means siteusers when SharePoint is queried server-side and profiles when it is queried client-side. Not case-sensitive.
/properties No Semicolon-separated list of additional properties to return. Department and Manager are always requested.

Result: empty. On success, Error may hold a warning (see Notes).

What the data source receives

The data source's dataFields content is replaced with GetUserProfileByNameResponse > GetUserProfileByNameResult > PropertyData, one PropertyData per property, sorted by name, each with a Name and a Values > ValueData > Value. With /source=siteusers the properties are:

Property name Contents
PreferredName Display name
Email, WorkEmail E-mail address
AccountName, LoginName Login account
Title Job title
Picture Picture URL
FirstName, LastName, WorkPhone, MobilePhone, Office, WebSite, UserName, IsSiteAdmin, Created, Modified When the site's user information has them
Department, Manager, and the names in /properties When the site's user information has them

Examples

GetUserProfileByName /source=siteusers
GetUserProfileByName /source=profiles /properties=Manager;Office
GetUserProfileByName /user-xpath=/my:myFields/my:ManagerAccount /dsname=ManagerProfile

The first loads the current user's profile. The third loads another user's profile (for example the manager's account name from a first call) into a second connection.

To copy a property into a field, use Set a field value with the Value whose PropertyData has the right Name, for example .../tns:Value[../../../tns:Name = "PreferredName"]. The prefix depends on your template.

Notes

Related: SetValue, GetValue.

8.9 GetTermPath

Returns the full path of a managed metadata term, for example Products;Hardware;Laptops, from term data that GetTermSets has already loaded.

Syntax

GetTermPath /termId=<term GUID> [/pathsep=<separator>]
Parameter Required Description
/termId Yes GUID of the term. Note the mixed case.
/pathsep No Separator between the levels. Default ;.

Result: the term's path, from the top-level term down to the term itself. A top-level term returns just its label.

Example

GetTermPath /termId-xpath=/my:myFields/my:ProductTermId /pathsep=/

Returns, for example, Products/Hardware/Laptops.

Notes

Related: GetTermSets, GetTermsByLabel.

8.10 GetTermSetIds

Finds the term sets used by the managed metadata columns of a list or library, and writes their IDs into the query fields of a GetTermSets connection to the SharePoint TaxonomyClientService. It is the first step before GetTermSets.

Syntax

GetTermSetIds [/list=<list name>] [/dsnamesrc=<data connection>] [/dsnamedest=<data source>]
Parameter Required Description
/list No List or library with managed metadata columns. Default Shared Documents.
/dsnamesrc No A data connection to the SharePoint Lists web service, used for its site URL. Default GetList.
/dsnamedest No The GetTermSets connection whose query fields are filled. Default GetTermSets.

Result: empty on success.

Example

GetTermSetIds /list=Products

Notes

Related: GetTermSets.

8.11 GetTermSets

Loads the terms of the term sets named in a GetTermSets connection's query fields (usually filled by GetTermSetIds) and stores them in the QdabraRules_TermSets data source, where drop-downs and GetTermPath can use them.

Syntax

GetTermSets [/dsnamesrc=<data connection>] [/dsnamedest=<data source>]
Parameter Required Description
/dsnamesrc No The GetTermSets connection to the TaxonomyClientService. Its query fields supply the term set IDs and lcid. Default GetTermSets.
/dsnamedest No Data source that receives the terms. Default QdabraRules_TermSets.

Result: empty on success.

Example

GetTermSetIds /list=Products
GetTermSets

Run as two actions in one rule: the first finds the term sets of the Products list, the second loads their terms.

Notes

Related: GetTermSetIds, GetTermPath, GetTermsByLabel.

8.12 GetTermsByLabel

Searches managed metadata for terms whose label matches a search text, and stores the matching terms in the QdabraRules_TermSets data source. Use it for a type-ahead or search box over a term store.

Syntax

GetTermsByLabel [/dsnamesrc=<data connection>] [/dsnamedest=<data source>]
Parameter Required Description
/dsnamesrc No A GetTermsByLabel connection to the TaxonomyClientService. Its query fields label (search text), lcid and matchOption are used. Default GetTermsByLabel.
/dsnamedest No Data source that receives the terms. Default QdabraRules_TermSets.

Result: empty on success.

Example

Set the connection's label query field from the user's search box, then run:

GetTermsByLabel

Notes

Related: GetTermSets.

Back to the Command Index.

© Qdabra Software  |  Questions and corrections: [email protected]  |  Preview copy, not linked from the public site.