# Database table of project properties

**URL:** <https://forum.inductiveautomation.com/t/database-table-of-project-properties/212>\
**Category:** Archived Topics\
**Created:** [February 23, 2007, 2:29am UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212 "2007-02-23T02:29:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bds](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bds](https://forum.inductiveautomation.com/u/bds)\
**Post date:** [February 23, 2007, 2:29am UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/1 "2007-02-23T02:29:19Z")

</div>

I have begun experimenting with using a database table to store project properties (onColor, alarmColor, etc). Works great so far for colors - I don’t have to worry whether I’m using the same shade on different screens, and I can change them all in one swell foop. Plus, I can query the database to change property state rather than enter color numbers.

However, some properties don’t seem so easily defined. For instance, is there some way to specify Border type or Font, etc in a DB cell?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 23, 2007, 5:05am UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/2 "2007-02-23T05:05:16Z")

</div>

First of all, kudos, this is a wonderful approach, especially for state-to-color and state-to-text lookups.

For the casual forum browser, let me explain how this works real quick. You set up a table in your database that might look something like this:

`TABLE: StateLookup
ObjectType State Text Color
"valve" 0 "Closed" "#BBBBBB"
"valve" 1 "Open" "Green"
"valve" 2 "Faulted" "Red"
"motor" 0 "Off" "#BBBBBB"
"motor" 1 "Hand" "Yellow"
"motor" 2 "Auto" "Green"
"motor" 3 "Faulted" "Red"
`

Then, for your valves, you set their color to be bound to a query like this:

```auto
SELECT Color FROM StateLookup WHERE ObjectType='valve' AND state = {Root Container.MyValve.state}
```

and the text to

```auto
SELECT Text FROM StateLookup WHERE ObjectType='valve' AND state = {Root Container.MyValve.state}
```

This may seem like a lot of work, but it effectively gives you the ability to define the logic of your objects in one place (the database), so if you ever add a new state or change the verbage or colors, you only change it in one place, not potentially tens or hundreds of on-screen objects.

Ok, back to your question, bds.

Unfortunately you’re right - there isn’t really a way to store borders or fonts in the DB. Even if there were some sort of string encoding for these properties, you currently can’t bind this type of property, so it wouldn’t help you much. Such a thing might be pretty useful, though, so I’ll enter it as a feature request.

Hope this helps,

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [February 24, 2009, 9:34pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/3 "2009-02-24T21:34:23Z")

</div>

Just checking on where this as I want to change the border in a script. I can’t find how to define a border in Jython and I can’t find any other reference to this on the boards.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 24, 2009, 10:24pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/4 "2009-02-24T22:24:04Z")

</div>

I’m glad you asked. There is now a relatively easy way to do this.

The easiest way is to make use of the expression language’s toBorder() casting function, which is (I just realized) undocumented, so I’ll go over it here.

It takes a string, which is of the format:

```auto
border(type; [options; options])
```

The available types are:  
[ul][li]line[/li]  
[li]etched[/li]  
[li]bevel[/li]  
[li]matte[/li]  
[li]paneltitled[/li]  
[li]etchedtitled[/li]  
[li]linetitled[/li]  
[li]button[/li]  
[li]field[/li][/ul]

Each type can take different options. For example:

```auto
border(line;red;5)
```

will give you a red, 5-pixel thick line border

More complex borders such as the panel titled border can take lots more options. We’ll get these into the docs - let me know what kind of borders you wanted to make in the meantime.

Now, you wanted to use scripting to create those borders. You can use the expression language like I have outlined above by simply binding the border in question to an expression like toBorder({Root Container.MyLabel.borderString}) where borderString is a dynamic property, and then you’d just set that dynamic property via a script.

(as an aside, you can also import javax.swing.border and go straight to the source…)

Now, fonts are a bit more tricky. You need to use Java, like this:

`from java.awt import Font
label = event.source.parent.getComponent("Label")
label.font = Font("Monospaced", Font.BOLD, 14)`

Hope this helps,

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [February 24, 2009, 11:46pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/5 "2009-02-24T23:46:42Z")

</div>

Bruce,  
I think you can accomplish everything you want using [styles](http://www.inductiveautomation.com/products/factorypmi/usermanual/source/Designer/conceptscompstyles.htm). I’m at a public terminal now, so I’ll have to check later on all of the properties (font/border) - as I recall, there is a text based encoding that allows you to store/modify them in a database table.

The [Styles Training Video](http://www.inductiveautomation.com/support/videos/?category=2&video=27) provides an example of storing styles in a database.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [February 25, 2009, 11:22pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/6 "2009-02-25T23:22:39Z")

</div>

Thanks Carl, that what I was looking for.

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [January 19, 2011, 10:46pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/7 "2011-01-19T22:46:48Z")

</div>

Nathan,

The styles video link just takes you to the video library page; I couldn’t find a video specifically about styles. I think I’ve seen all 14 training webinars and don’t recall one about linking styles to a database. I tried fooling around with it by creating a database table laid out just like a Styles recordset and then binding the styles property to a SQL query of that table instead of using the styles customizer. The query seems to work and if I examine the styles recordset it looks OK, but the state animation doesn’t happen.

For a multi-state indicator, my table looks like this:  
state int primary key  
animationIndex int  
animationDuration int  
background varchar(256) - this contains entries like ‘color(225,225,225,255)’  
border varchar(256)  
foreground varchar(256)  
text varchar(256)

It seems like this should work as long as your left-most column is the driving property. Am I barking up the wrong tree trying to use styles? Instead should I set individual properties with scripts as described by Carl?

Thanks.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [January 25, 2011, 4:50am UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/8 "2011-01-25T04:50:24Z")

</div>

This should work. Is your driving property actually called “state”?

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [January 27, 2011, 3:13am UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/9 "2011-01-27T03:13:58Z")

</div>

Yeah, I was first trying it on a multi-state indicator component that has a style customizer set up driven by state…

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [January 28, 2011, 7:15pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/10 "2011-01-28T19:15:03Z")

</div>

Can you export the problem window and send it to us?

---

<div class="post-metadata">

**Author:** ![MCC](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MCC](https://forum.inductiveautomation.com/u/MCC)\
**Post date:** [March 7, 2011, 2:59pm UTC](https://forum.inductiveautomation.com/t/database-table-of-project-properties/212/11 "2011-03-07T14:59:01Z")

</div>

I should update this… I found the issue was that one of my columns in my styles recordset resulting from my query was capitalized incorrectly. It turns out the columns in the styles table are case-sensitive.
