Proffix Px5 Add-in Connector

Use this connector for writing Add-ins for Proffix Px5.

Usage

You can use the connector as ECMAScript-Module, per example in HTML:

<script type="module">

// Use connector as ES2015-module
import { Px5AddInConnector } from "https://px5addinconnector.proffix.app/1/px5-add-in-connector.min.js";

// Define your own message handler for answers from Px5
const messageHandler = function (message) {
console.log("🥳 %cMessage received in my own message handler", "color: darkgreen; font-weight: bold", message);
}

// Instantiate a new connector
const px5 = new Px5AddInConnector("My Add-in", "1.0", "My Company", messageHandler);

// Change value of input control in Px5
px5.changeInputValueInPx5("dfsName", "New Value");

// Trigger event "GetControlsFromPx5" for getting values from input control of Px5
px5.getControlsFromPx5();

// Trigger event "GetInfoFromPx5" for getting infos from Px5
px5.getInfoFromPx5();

// Perform action in Px5
px5.triggerActionInPx5("PerformButtonClick", "pbtOk");

</script>

Available Files

Versioning and Changelog

This project follows SemVer. Every major version is deployed on a different URL: https://px5addinconnector.proffix.app/ combined with the major version number e.g. https://px5addinconnector.proffix.app/1

1.0.0

  • Initial Version

Communication Flow

The following messages are possible from or to Px5.

Register add-in

Triggered on creating new Px5AddInConnector instance.

Message from add-in

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "RegisterAddin",
"payload": null
}

Answer from Px5

None, except in case of an error

Change value of an input control in Px5

Triggered on method changeInputValueInPx5

Message from add-in

String Value:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "ChangeInputValueInPx5",
"payload": {
"controlname": "Px5Feldname_Text",
"value": "My new value"
}
}

Numeric Value:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "ChangeInputValueInPx5",
"payload": {
"controlname": "Px5Feldname_Numeric",
"value": 12.5
}
}

Boolean Value:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "ChangeInputValueInPx5",
"payload": {
"controlname": "Px5Feldname_Boolean",
"value": true
}
}

Answer from Px5

After changing the value on the Px5 form:

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "ValueChangedInPx5",
"payload": {
"controlname": "input1",
"value": "Value of input1",
"type": "pxText"
}
}

Error if input control doesn't exist:

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": "{\"currentpxform\":\"Px5 Form Name\",\"currentpxtab\": \"Tab 1\", ...",
"errortype": "NotFound",
"errormsg": "Human readable error message from Px5"
}
}

Error if value change of an input control is not allowed (e.g. it is readonly or disabled):

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": "{\"currentpxform\":\"Px5 Form Name\",\"currentpxtab\": \"Tab 1\", ...",
"errortype": "NotAllowed",
"errormsg": "Human readable error message from Px5"
}
}

Get controls from Px5

Triggered on method getControlsFromPx5

Message from add-in

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "GetControlsFromPx5",
"payload": null
}

Answer from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "GetControlsFromPx5",
"payload": [
{ "controlname": "input1", "value": "Value of input1", "type": "pxText" },
{ "controlname": "input2", "value": "Value of input2", "type": "pxText" },
{ "controlname": "input3", "value": 12.5, "type": "pxCurrency" },
{ "controlname": "input2", "value": false, "type": "pxCheck" }
]
}

Get environment informations from Px5

Triggered on method getInfoFromPx5

Message from add-in

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "GetInfoFromPx5",
"payload": null
}

Answer from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "GetInfoFromPx5",
"payload": {
"pxversion": "PxVersion",
"dbname": "DBName",
"dbpath": "DBPath",
"dbuser": "DBUser",
"loginuser": "LoginUser",
"logingroup": "LoginGroup",
"readonly": false,
"connectionstring": "ConnectionString",
"skin": "Skin",
"restapiurl": "RESTAPIURL",
"webservicepassword": "WebservicePassword",
"logintoken": "LoginToken"
}
}

Trigger action in Px5

Triggered on method triggerActionInPx5

Message from add-in

Click on a button on Px5 form:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "TriggerActionInPx5",
"payload": {
"action": "PerformButtonClick",
"controlname": "Px5Control"
}
}

Disable control on Px5 form:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "TriggerActionInPx5",
"payload": {
"action": "DisableControl",
"controlname": "Px5Control"
}
}

Enable control on Px5 form:

{
"connectorversion": "1.0.0",
"addin": { "name": "My Px5-AddIn", "version": "0.1", "developer": "My Company" },
"method": "TriggerActionInPx5",
"payload": {
"action": "EnableControl",
"controlname": "Px5Control"
}
}

Answer from Px5

None, except in case of an error

Button for clicking not found:

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": "{\"currentpxform\":\"Px5 Form Name\",\"currentpxtab\": \"Tab 1\", ...",
"errortype": "NotFound",
"errormsg": "Human readable error message from Px5"
}
}

Enabling or disabling of a control not allowed (e.g. by default disabled controls can not enabled):

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": "{\"currentpxform\":\"Px5 Form Name\",\"currentpxtab\": \"Tab 1\", ...",
"errortype": "NotAllowed",
"errormsg": "Human readable error message from Px5"
}
}

Input value has changed on Px5 form

Triggered on leaving a control input on Px5 form

Message from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "ValueChangedInPx5",
"payload": {
"controlname": "input1",
"value": "Value of input1",
"type": "pxText"
}
}

Current tab has changed on Px5 form

Triggered on switching tab on Px5 form

Message from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "TabSwitchedInPx5",
"payload": null
}

Error from Px5 in case of an invalid message

Triggered if Px5 receive an invalid message from add-in

Message from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": ">>> not supported message <<<",
"errortype": "InvalidMessage",
"errormsg": "Human readable error message from Px5"
}
}

Error from Px5 on general error

Triggered if Px5 reports an unspecified error

Message from Px5

{
"currentpxform": "Px5 Form Name",
"currentpxtab": "Tab 1",
"method": "MessageErrorInPx5",
"payload": {
"origin": "{\"currentpxform\":\"Px5 Form Name\",\"currentpxtab\": \"Tab 1\", ...",
"errortype": "General",
"errormsg": "Human readable error message from Px5"
}
}