Business Assistant
Language support for Business Assistant .ba files in VS Code.
A folder with ba.json is a Business Assistant project. .ba files describe pages, profiles, and role centers using unquoted field names, enums, and symbols. Strings must use single quotes. Double quotes wrap a symbol that is not a plain identifier.
Features
- Syntax highlighting for field names, enums, symbols, strings, and numbers
- Completions and hover docs for pages, profiles, and role centers
- Go to Definition on page names such as
CardPage, DialogPage, SubPage, and DrillDownPage
- Snippets:
page, profile, rolecenter, control, field
- Page extensions: a
PageExtension adds fields and actions to a page of another app (Extends: "General Ledger Entries"), as a Business Central pageextension. Its fields are checked against the table of the page it extends, including fields that table extensions add.
- Role center extensions: a
RoleCenterExtension adds groups of tiles and charts to a role center of another app (Extends: "Administrator Rolecenter"), after its own groups. Its groups are written and checked as a role center's.
- Batch fields: a Worksheet's
BatchField is chosen above its lines, as a journal's Batch Name
- Images: a role center tile's, a page action's and a profile item's
Image names one of Business Assistant's images (Image: Customer, Image: Post), as Business Central's Image property does. Completion shows each one's picture, and so does hover; a name that isn't one is an error. The set is the web app's (BA.Platform's src/assets/images.svg): after it changes, npm run images writes src/imageSet.ts from it.
- Report layouts: a
.barpt opens as JSON; Open in Report Designer (right-click it) opens it in the Report Designer, the Windows app that designs layouts.
- Format Document
- From Json converts a JSON page, profile, or role center to BA and renames
.json to .ba
- Convert All To BA converts matching JSON files in the project
- Rename Files names
.ba files from kind, id, and name
- Package renames
.ba files, then builds a {AppName}.app zip (includes ba.json and the pages, profiles, and role centers)
- Publish packages the app and uploads that
.app file to your Business Assistant server
- Download Symbols fetches table metadata from the server into
.bapackages for page completions, hover, and validation
Project settings
Create ba.json in the project root:
{
"id": "ba.finance",
"name": "Finance",
"type": "Standard",
"developer": "Passioncloud",
"version": "1.0.0.0",
"licenseNo": "LIC-FINANCE",
"homepage": "https://passioncloud.net",
"idRange": [
{ "from": 1, "to": 5000 }
]
}
type says what the app is:
|
Standard (Finance, Payroll) |
Customization (one customer's changes) |
| Depends on |
Standard apps only |
Standard and Customization apps |
| Publish to |
the marketplace (Publish to Marketplace) |
its customer's instance (Publish), never the marketplace |
| launch.json |
optional: to try it on a Sandbox instance |
required: names the instance |
licenseNo |
required |
not needed (billed through the instance's usage) |
Marketplace fields (description, icon, readme…) |
shown on the marketplace |
not allowed |
A Production instance gets a Standard app only by installing it from the marketplace. Download Symbols for a Standard app needs no launch.json: it signs in to Passioncloud and takes each dependency (and theirs) from the marketplace.
Every developer has its own ids on Passioncloud (Business Assistant → Developers → Id Ranges), which Passioncloud staff set. An app's idRange must be within its developer's ids and apart from the developer's other apps; every page, report, dialog, profile, role center and page extension takes an id from it. Passioncloud refuses a package that doesn't. Publish without an instance in launch.json goes straight to a server, and only to one on this computer (localhost).
Put the server in .vscode/launch.json, so it is not packed into the app:
{
"baseUrl": "https://localhost:5001"
}
baseUrl works with or without /api at the end.
Signing in is with Passioncloud. The first time, VS Code opens Passioncloud's sign-in in your browser, where you allow VS Code; it keeps the sign-in and renews it without asking. A server signs you in as the user whose card has your Passioncloud email (a development server needs ControlPlane:Authority in its settings). The status bar shows who is signed in; Business Assistant: Clear Credentials signs VS Code out. Your browser stays signed in to Passioncloud: to allow VS Code as someone else, choose "Use another account" on Passioncloud's page.
Then run Business Assistant: Download Symbols from the Command Palette, then Business Assistant: Package or Business Assistant: Publish.
Download Symbols also puts the app's C# on the BA.Core that ba.json's Core dependency asks for: it sets BA.Core's package version (1.0.37.0 is the package 1.0.37) where the project sets it, in Directory.Packages.props or the project's PackageReference, and restores the project. To move an app to a newer BA.Core, raise that version in ba.json and Download Symbols.
id, name, developer, version, and homepage are packed into {AppName}.app with the pages, profiles, and role centers. Page, profile, and role center Id values must fall in idRange. Publish sends that .app file to {baseUrl}/Publish.
Publishing a module through the Business Assistant Manager
A module is C# code (a .csproj next to ba.json, or the one ba.json's "project" names) plus .ba pages.
Business Assistant: Package Module builds both into one module package, .bapackages/{Name}_{version}.bapkg:
- the project's assemblies, less those every server already has (BA.Core, and other
BA.* modules);
- the
.app;
- a
module.json.
The C# project's version must be ba.json's.
With an instance in .vscode/launch.json, baseUrl is the Business Assistant Manager, instance is the server it manages that this project works with (its name or code), and environmentType, which is required, is that server's: Sandbox or Production. A Sandbox and a Production server may have the same name, and the environment says which one you mean; Publish stops when the server is of the other environment.
{
"baseUrl": "https://admin.passioncloud.net",
"instance": "BA-1001",
"environmentType": "Sandbox"
}
Download Symbols is that server's. You are signed in to it as the user whose card has your Passioncloud email.
Publish sends the module package. The manager asks that server whether you may publish there, then deploys the package:
- The server is stopped, the module put in, and the server started again.
- The server syncs its tables and publishes the pages.
- If the server does not come up, it is put back as it was.
The Business Assistant output follows the deployment until it has finished.
"failOnDataLoss": true makes a deployment fail, and be rolled back, rather than drop the fields and tables the module no longer has. Without it, they are dropped with their data.
Without instance, Publish sends the .app to baseUrl as before.
Downloaded symbols and packaged apps are stored in .bapackages/ next to ba.json as zip files, not as readable JSON — for example Finance.app. The folder is hidden in VS Code by default. Add .bapackages/ to your project .gitignore. After symbols are downloaded, page SourceTable values and field names are completed and validated against the server tables.
Publishing a module to the marketplace
Business Assistant: Publish to Marketplace puts the module on Passioncloud's marketplace (Business Assistant → Marketplace in the admin portal), as vsce publish puts an extension on VS Code's. It packages the module as Package Module does and sends it to Passioncloud, signed in to Passioncloud as a staff member. The app is then listed, and is deployed to no instance. Core is published there too, so its updates go out as any app's do.
The marketplace shows what the package brings, from ba.json and the files next to it:
{
"licenseNo": "LIC-FINANCE",
"description": "Books, ledgers, sales and purchases.",
"categories": ["Finance", "Accounting"],
"icon": "marketplace/icon.svg",
"screenshots": ["marketplace/sales-orders.png"],
"readme": "marketplace/README.md",
"changelog": "CHANGELOG.md"
}
licenseNo (required) is the license the app requires: one of its developer's licenses on Passioncloud. Its price is the app's.
readme and changelog default to README.md and CHANGELOG.md next to ba.json. The pictures they show by a relative path are packed too.
- The counts of tables (from the C# project), pages and reports are worked out by Package Module.
- Where it is published is the setting
businessAssistant.marketplaceUrl, https://admin.passioncloud.net by default.
The module's C# and its pages together
The extension also reads the tables in the project's own C# files, every time one is saved. These are classes deriving from Table<...> or SetupTable<...>, and [TableExtension(typeof(X))] classes, whose fields go on X. In practice:
- A field added to a table class, say
public LocalDate PromisedDate { get; set; } on SalesHeader, is in the .ba files' completions, hover and validation as soon as the file is saved. A new table class is too. No build, publish or Download Symbols is needed.
- The field's caption comes from
[Display(Name = ...)], else from its name, and its tooltip from Description. Its type, key, enum values and whether it is editable are read from the C#.
- What the downloaded symbols already say about a table or field stays as they say: the C# adds what the server does not have yet.
- Go to Definition (F12, or Ctrl+Click) on a page's
SourceTable, or on a field name, opens the C# class or property.
Download Symbols is still needed for the tables of BA.Core and of the modules this one depends on.
Example
Page {
Id: 30
Name: 'Item'
Caption: 'Item'
PageType: Card
SourceTable: Item
PageActions: []
PageControls: [
{
ControlType: Group
Caption: 'Item'
Fields: [
{ Name: No }
{ Name: Description }
]
}
]
}
Table and field names (SourceTable, control Name, FieldName, RelatedFieldName) are symbols. Write SourceTable: Customer, or use double quotes when the name is not a plain identifier: Name: "No.". Page references use the page name the same way: CardPage: GLAccountCard or Page: "Chart of Accounts". Double quotes around a symbol are part of the name syntax, not a string. String properties such as Name and Caption use single quotes: Name: 'Item List'.
Press Ctrl+Space for completions. Hover a field for its documentation. Hover or Ctrl+Click a page name such as CardPage: GLAccountCard to see and open that page. Use Format Document to pretty-print BA. Format also rewrites older CardPageId / PageId keys to CardPage / Page, and double-quoted strings to single quotes.