Starting workflow from the SharePoint document library

Facebooktwitterpinterestlinkedinmail
Applies to version: 2020.1.x and above; author: Michał Kastelik

 

The article describes the way of using the advanced column formatting in the SharePoint library to start the WEBCON BPS workflow and how to download an attachment from the SharePoint library for the workflow as an attachment.

Preparation the document library view

Additional columns have been added to the standard view of the document library:

  • BPS URL – hyperlink column which stores the workflow instance address
  • Status – text column which stores the current workflow status
  • Start – text field with a start link for the workflow

The prepared view is as follows:

 

To add a start hyperlink to the workflow, select the “Start” column settings and then, select the “Format this column” option.

 

Then paste the previously prepared JSON code:

  “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”, 

  “elmType”: “a”, 

  “txtContent”: “=if([$Status]==’’,’Start WEBCON BPS!’, if([$Status]==’In progress’, ‘’,’’))”, 

  “attributes”: { 

    “target”: “_blank”, 

    “href”: “=’https://presentation.webconbps.com/BPSPortal/db/1/app/71/start/wf/145/dt/148/form?com_id=2&returnurl=%2Fdb%2F1%2Fapp%2F71&AttText1=’ + [$FileLeafRef] + ‘&AttText4=’ + [$ID] + ‘&AttText3=’+[$FileRef]” 

  } 

Depending on the “Status” column value, a “Start WEBCON BPS” text is displayed in the SharePoint library view; there is a simple function here:

if([$Status]==’’,’Start WEBCON BPS!’, if([$Status]==’In progress’, ‘’,’’))”,

 

The WEBCON BPS workflow is started from the hyperlink that contains the following fields:

  • Name (AttText1) a field in which the document name ([$FileLeafRef] variable) is stored
  • ID (AttText4) a field in which the file ID is stored
  • Item URL (AttText3) a field in which the file name ([$FileRef]) variable) is stored

 

After moving to the next step, the workflow has the following actions defined:

  • Update status – updating the Status column in the library
  • Insert BPS link – saving the link to the WEBCON BPS instance
  • Download document – an action downloading the instance from the SharePoint library and saving them in the WEBCON BPS library

 

If the value of the SharePoint document library form was updated, the Edit a list element” action was used. The configuration of the “Insert BPS link” action is presented below:

 

The ID field contains the instance ID from the SharePoint library to be updated.

Downloading the attachment and saving in the workflow

A field which identifies the document in the case of an attachment download from the SharePoint library, is the “Item URL” form field in which the [$FileRef] value is stored in the format „/Start BPS Library/SuperHero.png”. The missing part to the entire hyperlink is stored in the additional “Connection” field.

 

After executing all three actions, the attachment from the SharePoint document library is saved in the WEBCON BPS workflow. Also, the current workflow step is saved in the “Status” field on the SharePoint document list, the link to the WEBCON BPS instance is saved in the BPS URL field and the starting link from the “Start” field is hidden.

The WEBCON BPS form view:

 

The SharePoint document library view:

 

Starting a workflow by using the SharePoint list was described in this article -> https://kb.webcon.pl/startowanie-obiegu-za-pomoca-listy-sharepoint/.

Leave a Reply

Your email address will not be published. Required fields are marked *