
Shareflex Code
Shareflex Code is an extension to support working on Shareflex Online projects using Visual Studio Code.
Shareflex Online
The Shareflex Online product family comprises all cloud-based software solutions offered by Portal Systems. These include ready-to-use business applications, such as the Shareflex Contract Online contract management system, which can easily be configured and customised. Moreover, with Shareflex ECM Online, we now offer you a modern, holistic alternative to classic ECM systems, too.
All these business solutions are based 100% on SharePoint Online and integrate seamlessly into your Microsoft 365 (formerly Office 365) environment. This way, they offer you all the advantages of a modern cloud architecture.
Features
Requirements
In order to being able to use this extension, a Microsoft SharePoint Online site collection with deployed "Shareflex Online App" is required.
Commands
Press F1 to open the command palette and type ShareflexCode
.

Command |
Description |
Add Connection |
Create a new Connection to a SharePoint Online Site Collection and save it to local Workspace configuration |
Create standardized folder structure |
Ensure local workspace folder structure according to Shareflex projects best practices |
Debug Script with Shareflex CLI |
Execute current Shareflex script in DEBUG mode with installed Shareflex CLI |
Get 'ShareflexRules.d.ts' of current Connection |
Download Shareflex Rules type definition of active Connections build number |
Initialize Workspace |
Prepare local Workspace for usage of ShareflexCode extension |
Open Log In Editor |
Open the current output of Shareflex Code in a new editor document |
Open Provisioning WebIDE |
Open the Shareflex Provisioning WebIDE of the current active Connection |
Open Provisioning Script in WebIDE |
Open current script in the Shareflex Provisioning WebIDE of the current active Connection |
Open Shareflex Online Services page |
Open the Shareflex Online Services page of the current active Connection |
Remove Connection |
Delete a Connection from local Workspace configuration |
Rename Connection |
Rename a Connection of local Workspace configuration |
Run Script with Shareflex CLI |
Run current Shareflex script with installed Shareflex CLI |
Set Connection |
Select the Connection to be used for upload and download of files and folder and also for execution of Shareflex Provisioning scripts |
Set maximum number of parallel uploads |
Configure the amount of files that are uploaded at the same time when uploading a folder |
Set Project Name |
Set name of workspace Project to be used when creating standardized folder structure by command |
Set Provisioning API Key |
Set a valid API key for Shareflex Provisioning execution and save it in security storage |
Set Shareflex CLI |
Set a CLI to execute Shareflex scripts with (CLI has to be installed separately) |
Start Provisioning Script in WebIDE |
Start current script in the Shareflex Provisioning WebIDE of the current active Connection |
Switch User Context |
Change user account to be used for active Connection to SharePoint Site |
Upload File |
Upload current file to SharePoint Site Collection of active Connection |
|
|
Getting Started
Use command Initialize Workspace
to set up the workspace for usage of the Shareflex Extension. The Project Name
will be used when ensuring the recommended folder structure.
To enable transactions with a SharePoint Site Collection, at least one Connection has to be configured.
It's possible to configure multiple Connections. File transactions will therefore use the active Connection.
All Connection information is kept separately for each Visual Studio Code Workspace.
Use command Add Connection
to create a new Connection to a SharePoint Online Site Collection.
Use command Set Connection
to select the Connection to be used for SharePoint transactions, if you have multiple Connections.
File handling
Local folder structure
In addition to setting up the correct Connection to SharePoint Online, the structure of the local Workspace must correspond to the standard file structure of a Shareflex project.
In general the Workspace has to have a directory src
. This folder has different subfolders, representing the default Shareflex document libraries of the Core web ("../pscBAF"
). So each subfolder of src
has a corresponding document library in the Core web with the same technical name.

Only files and folders located in these document library representing folders can be used for file transactions.
Additional folders (e.g. dist
) representing the Core web can be configured in the Extension Settings web mappings.
Ensure local folder structure
Use command Create standardized folder structure
to ensure the recommended Shareflex projects folder structure for the local workspace.
For some folder paths the local Project Name has to be added dynamically. The Project Name is configured when this command is executed for the first time or by running the command Initialize Workspace
. The Project Name can be changed by using command Set Project Name
or also by modifying the Extension Settings directly.
Every time the command to create the folder structure is executed, missing elements of the recommended folder structure will be added. No data will be overwritten or deleted.
Upload File
There are different ways to upload a file to the SharePoint Online Site Collection of the active Connection:
- Use Command
Upload File
to upload active editor file
- Use shortcut
Shift + Alt + U
to upload active editor file
- Right-click in active editor and select
Upload File
in context menu to upload active file
- Right-click specific file in Visual Studio Code file explorer and select
Upload File
Upload Folder
It is also possible to upload a whole folder (recursive) to the SharePoint Online Site Collection of the active Connection:
- Right-click the specific folder in Visual Studio Code file explorer and select
Upload Folder
Note: All files are being uploaded in parallel. To adjust the amount of files that are uploaded simultaneously, the command Set maximum number of parallel uploads
can be used (performance vs. stability)
Download Folder
To update local files with the data from SharePoint Online it is possible to download folders of the active Connections Site Collection.
ATTENTION: This will overwrite local files in the Workspace!
- Right-click the specific folder in Visual Studio Code file explorer and select
Download Folder
Available Snippets
To make it easier to get started with new scripts, this Extension adds snippets to Visual Studio Code.

Shareflex Rules
Trigger |
Description |
#rns |
R ules N ew S cript - Basic script structure for an event or timerjob Shareflex Rules script |
#rnts |
R ules N ew T est S cript - Basic script structure for a backend test Shareflex Rules script |
|
|
Trigger |
Description |
#fns |
F orms N ew S cript - Basic script structure for an UI Shareflex Forms script |
|
|
Extension Settings #
This extension contributes the following settings:
settings.json
shareflex.activeConnection
- Name of active SharePoint Connection per local Workspace
"shareflex.activeConnection": [
{
"name": "con1", // Currently used Connection
"path": "c:/_Repos/Contoso/.vscode/shareflex.json" // Config file of local Workspace
}
]
shareflex.cliContext
- Name of active Shareflex CLI to run Shareflex scripts with
"shareflex.cliContext": "sflx"
shareflex.maxParallelUploads
- Maximum number of files that are uploaded at the same time when uploading a folder
"shareflex.maxParallelUploads": 10
shareflex.json
In addition, a local configuration file is created for each Visual Studio Code Workspace under ./.vscode/shareflex.json
.
So all Connection information is kept separately for each Workspace.
projectName
- technical name of the project to be used for recommended folder structure
"projectName": "MyCustomProject"
webMappings
- Mapping of SharePoint web to local folders
"webMappings": {
"pscBAF": [ //Mandatory
"src" //Example
],
"Custom": [ //Example
{
"localPath": "src/Custom", //Local file/folder-path
"targetSubWeb": "sub1/sub1a", //SharePoint subweb. Relative to "con1"s "url"-property
"targetWebRelativePath": "Shared%20Documents", //SharePoint webRelativePath
"connections": [
"con1" //Connections, that use this custom-setting
//Custom-setting will be used when one of the "connections" (in "Custom") is matching the "shareflex.activeConnection"
],
},
//...
]
}
connections
- Array of SharePoint Connection objects
"connections": [
{ //Example
"name": "con1",
"url": "https://contoso.sharepoint.com/sites/yourSite"
},
{
//...
},
]
Known Issues
- If user is prompted in Browser to switch the Microsoft Azure Tenant (MFA) due to the current active Connection, commands using the Shareflex Provisioning WebIDE will open the Shareflex Online Service page for this very first request (instead of WebIDE page). Every later usage of this command will open the Shareflex Provisioning WebIDE correctly.
Coming Soon
- VSCode Multi-Workspace support for Connection handling
Support
In case of experiencing an issue with Shareflex Code, please contact us at support@portalsystems.de.