- Property Watcher on an empty value


Property Watchers can be used to evaluate the value of one property to determine the value of a second property. 

In this example, if the Date field is not set, then PropA will be 3003.  On the other hand, if the Date field is set, then PropA is set to any value from the domain list.

To do this, PropA is defined as a comboBox with a series of values.  This would be a typical combo box that you would create for your project.

In the ComboBox Properties, the default initial value is set to the value to be used when the Date field is empty.  For our example, that's 3003.

For the Date property, the Show None option is enabled.  This easily overlooked setting adds a tick box to the Date property.  When toggled off, the Date field will be empty as shown in the Data Browser.

A property watcher is added to the Date with the following settings:

Name:  A descriptive name

Type:  SynchItem - This type of watcher is used to establish relationships between different feature properties. If a match value is provided, the current property’s value must equal this value for the watcher to execute. 

Feature:  The name of the feature that will be updated

Property:  The name of the property of the feature to be updated

Value Type:  cexpression - These expressions are preprocessed by XFM and then passed into MicroStation's C-expression handler for evaluation. Any valid C language function available in MDL can be used to define criteria. See the Criteria topic in the OpenCities Geospatial Administrator help. 

Redraw Watcher:  On - This redraws the item associated with the property being changed. It's used to change the enabled state of a dialog item and/or to reload the list of values.

Value To Set:  (strlen("[MyBlock:Date]")>0) ? "[MyBlock:PropA]" : "3003"  This says that if the Date property value length is greater than zero, then the PropA value is set to the current value of PropA.  Otherwise the PropA value is set to “3003”.  The  strlen returns the length of a string, that's expressd in the number of characters.  For example, n = strlen(“hello world”) results in 11.

Note:  The Date property value length is zero when the Show None toggle is OFF on the data time dialog item.

For more information, please refer to:

 Expressions, Operators and Basic Functions

Attached is a sample schema that you can use for testing:

communities.bentley.com/.../Property-Watcher-on-empty-value.zip