How do I create data subscriptions?

Since real-time access to interact with on-premise and cloud data is a cornerstone of what we do, creating data subscriptions are a pretty important part of building bezls!

I am starting in the custom builder on a blank bezl.

2019-10-02 15_10_25-Window

I will right click on data subscriptions, and select Add New.

2019-10-02 15_11_17-WindowBy default it’s called, but you can right click to change the name. Note that accessing it in code or in your user interface it will be or whatever you name it to.

2019-10-02 15_11_48-Window

I am going to click Edit, which will take me to the screen to configure the data subscription.

First I will pick the connection, this is the Bezlio connection we are joining. Connections are configured by clicking the My Info menu, and selecting Update Data. Each connection will be listed there.

2019-10-02 15_15_15-Window

Next I will select my resource. Resources will either by plugins installed on the server (like SQL Server which I will use) or Dynamic Plugins created via C# code on the server.

2019-10-02 15_16_19-Window

What you see once you have picked your resource will change depending on the resource and what it has available. Dynamic plugins will allow you to select a method to execute, SQL has some additional questions for me.

2019-10-02 15_18_05-Window

I selected the method to execute a query, from a folder I have shared called CRM, using a connection I shared named Production, and I’m executing a query called GetContacts.

My query has a parameter in it, this is the sql query I have created:

ERP.CustCnt cc WITH (nolock)
cc.Company = '{Company}'
AND cc.ShipToNum = ''

The {} in the query is a parameter, so under Parameters, I will click the blue Add button which creates a parameter. In the Key I will put Company which matches the parameter in the query.

2019-10-02 15_21_03-Window

Now for the value I could just type EPIC06 in there or I can use the button to the right for different options.

2019-10-02 15_22_01-Window

I have a variable called Company, and I can use that value which helps for data binding! You can also access custom user properties via:

For a property called UserId. Custom user properties can be added from My Info -> Update Profile.

Just a couple more options now!

2019-10-02 15_24_25-Window

The subscription type you mark if its Read Only or Write Back. This is mostly used for Offline Mode, where offline Write Back transactions will be queued for when the user gets signal again.

On Demand is a really powerful flag, by default data subscriptions will execute when the bezl is launched, but if I’m filling in a variable and I want that variable to be used in the query that’s not very helpful is it. Marking it as On Demand will tell Bezlio to not automatically run that query. You can then call to run the query in code by using:


You can call that function at any time, and it will reprocess the query even if it has been run before.

The refresh interval will automatically refresh the query in a set number of minutes. 0 disables the auto refresh.

I can then click the Verify button and it will execute the query and show you the results in the bottom section.

2019-10-02 15_28_46-Window

Now you can Save and Close and you have a data subscription added to your bezl. You can use that in your user interface, but there is one more function that is important to know, and that is onDataChange.

onDataChange is called every time data is returned from a data subscription, so you can use that as a trigger to do other things. You can write typescript in the function, data is returned as or whatever you renamed your data subscription too. Another important thing to note is

2019-10-02 15_32_04-Window

The variable is a string of what data subscription is calling onDataChange. Because Bezlio is fully async, this allows you to know what data subscription is returning and act accordingly.