Background color dynamically based on SQL database description row

Hi guys, I’ve been playing with this for a while and I couldn’t find the right solution for this, one of my customers wants to add background color to a few objects based on a description row coming from a workbench 8.0 database table, any thoughts on that? (Vision)

I’ve been thinking on apply named queries, but I don’t have too much experience with those,
any help will be really appreciated.

Thank you,

Is the list of descriptions from the table more or less static? (i.e. You might add rows to it every so often but generally it’s the same otherwise)
Would it make sense to add the colour into a new field in the table?
I assume that to determine the description for a component and hence its background colour, you look it up based on a dynamic tag value or something?

The list is not static, here is a brief description of what we are trying to accomplish.

.- They have a database stored in workbench 8.0 in the database a table with the information of the conveyors is inside, conveyor name, last maintenance, conveyor fault, etc.

.- They want to be able to search inside the table and if the conveyor name appears in the table ie: 350 is in one of the rows then display red or flashing red the object or piece of conveyor in the screen, we’re using the conveyor’s name dynamic and everything, is there any way to make this happens? Named queries could be a solution or something different?

I tried to accomplish this adding and expression, but when I look inside the properties of the table only Data, Selected column, Selected row are the options I don’t see any search data or data on this row i.e = 350.

Ok, so it’s a tool to search for conveyors to locate them on the page?

I would use 2 client tags, one with the filter text, one that stores a dataset. When the filter text changes, fire an event using an onChange script on the filter text client tag that will run a script to query your database table (using a named query) and return a list of the conveyors filtered to that text. Write the results to the client dataset tag.

Then in your conveyor templates, use the lookup function to check if that conveyor is in the list, if so, light up the disco

Yes a named query can do the job.
I would first add a field of where user may type, a text field.

Add a internal property to your conveyor draw (hope to be a template) and an external property that will be the comparison field. On the first property (internal) use named query. Then use a background binding saying if your dynamic id is equal to your search field and extra conditions then be red. Write a property event script at the root and when it changes, do a system.db.refresh().

Finally bind the text property of text field to external property of your template.

I’d stay away from calling a query binding (even a cached named query) on potentially 10’s/100’s of components on the screen from a performance standpoint; queries are expensive! I would much rather do this query once in a client tag and reference that everywhere. Using a query binding on each conveyor will also be more difficult to handle multiple results returned and will increase client memory usage since every component will now need to store a dataset property with the results of the query.

servers are meant to handle this load

Better to design efficiency into your applications so that you don’t have to upgrade your server more often than necessary and potentially have unperformant clients

First of all, thank you so much for all your comments those really helped me with this process.

Here’s an update about what I have.

I ended up using a named query for the table, I have a screen where I added a table on it displaying a named query, I used a dropdown list as well.

Here’s how looks my table on the named query.

SELECT Company_AL.area,,
FROM Company_AL
INNER JOIN conveyor_info ON Company_AL.ID = Conveyor_info.ID

where area = :area;

on my main screen, I have the table plus the dropdown list with the area names, when I sort by area name I can see the conveyors affected on that area.
; therefore I added a label_1 that shows me the row selected " expression (try({Root}[{Root Container.Table.selectedRow}, “cnvy_name”], 0) ".

The conveyor’s squares are templates where we have parameters one of the parameters is the conveyor name, we are doing this comparison to change the color to red.
Expression: IF({Root Container.Label 1.text} = {[AL]Conveyor 101/Parameters.Conveyor_name},“255,0,0”,“255,255,255,0”)

Obviously, this is only working when the row is selected and the name is the same as parameter conveyor_number, I’m still looking for a way to do this automatically by searching in the column cnvy_name and doing the functionality in the conveyor square.

That’s where, as I said in my other post, you can use a client tag to store the area filter and another client tag bound to a named query which filters on the area client tag. If it’s only ever supposed to return one conveyor, you can use a scalar query and only return cnvy_name. So then you have 2 client tags, one with the filter and one that returns a string with the cnvy_name. Then bidirectionally bind the dropdown selection value to the area filter client tag, and use the cnvy_name client tag in here in place of the label 1 text: