SETPROPERTY

This function is used, as part of an action, to save multiple properties into XML. When not used with an action, SETPROPERTY cannot modify XML - it only returns the current XML. For example, this formula, as part of a Set Parameters action, writes to a variable called DemoXML:
=SETPROPERTY(ReportVariables.DemoXML.Text, "visibility","ReportObjects.ListView6.Alias" ,"false")
But, when inserted in a cell, the same formula returns the current value of the DemoXML variable:
<Table><Row name="visibility"><Property name="ReportObjects.ListView6.Alias" value="False" /></Row></Table>

So, to modify the variable, you must use an action that assigns the output returned by the SETPROPERTY function back to the variable.

For example, on a listview object, such as a combo box, define a Set parameters action to be triggered when the selection in the combo box changes. In the Parameters section of the Create Action dialog box, select the variable to be populated as the Name, and the define a SETPROPERTY function as the Value. In View mode, the parameter is populated when the action is triggered.

You can add, modify, or delete any property.

You can use the function to set a single property and value or multiple properties, each with a value. Use it, for example, to populate an XML variable with the values of the slice dimensions in a report. You can also use the function to delete properties and values from a variable.

SETPROPERTY can be used to reference specific elements or can be used to reference hyperblock cells.

To return values from the properties of a variable use GETPROPERTY .

You can use the asterisk (*) character at the beginning or end of a string as a wildcard. For example, to return particular keys or properties. Asterisks within a string do not act as wildcards. A wildcard search returns only the first matched key or property.
Note: We cannot guarantee the order in which keys or properties are matched.

These examples are based on the Samples application and use properties named Unique and Caption to store the unique name and caption of an element:

Syntax

SETPROPERTY("XML_properties","key","property","value")

The first argument of the formula can be a variable or string.

The * wildcard character can be used with the key and property arguments to overwrite or delete multiple values simultaneously.

Examples of single properties and values

  1. =SETPROPERTY(globalvariables.gv_property,"[Product]","Unique",
    "[Product].[All Tires].[Car Tires All Season]")
  2. =SETPROPERTY(globalvariables.gv_property,reportobjects.Hyperblock4.Text,
    "Unique","[Product].[All Tires].[Car Tires All Season]")
  3. =SETPROPERTY(globalvariables.gv_property,"reportvariables.rv_dimension.text","Unique",
    "reportvariables.rv_element.text")

In all three examples, the Product dimension is the key and the property name is 'Unique'.

In the first example, the Product dimension and the unique name of a product are specified. In the second example, the name of a hyperblock containing the Product dimension is specified. The third example references report variables that contain a dimension name and an element unique name.

In the XML definition the key forms the row name.

Set multiple properties and values

SETPROPERTY("XML_properties", "key", "property","value",{,"property"}{,"value"})

Example

=SETPROPERTY(globalvariables._gv_property,"[Product]","unique","[Product].[All
		Tires].[Car Tires all Season]","Caption","Car Tires all Season")

Multiple keys

You can store multiple keys in a variable, but not with a single SETPROPERTY function. To store multiple keys, use a hyperblock or nest multiple SETPROPERTY functions. For example:
=SETPROPERTY(SETPROPERTY("XML_properties","key","property","value"),
"key","property","value") 

Each key forms a row in the XML definition of the variable.

Or, use multiple SETPROPERTY formulas in multiple actions to populate a single XML variable - for example to store the filter dimensions in a dynamic report.

Delete a single property

SETPROPERTY("XML_properties", "key", "property","")

Example

This deletes the Caption property from a variable that stores the unique name and caption of an element of the Product dimension.

=SETPROPERTY(globalvariables._gv_property,"[Product]","caption","")

Delete multiple properties

=SETPROPERTY("XML_properties","key","property","","property,"")

Delete all properties of a row

=SETPROPERTY("XML_propertes","key")

SETPROPERTY in hyperblocks

The SETPROPERTY function can reference hyperblock cells. When used with hyperblocks, it is possible to define these combinations of keys, properties and values in an XML variable:

  • One key with multiple property and value pairs
  • Multiple keys with one property and value pair
  • Multiple keys with multiple property and value pairs
  • Multiple keys with multiple properties and one value

Examples

These examples use a vertical hyperblock in cells B2, B3 and B4 and a global variable called gv_SetProperty. Cell B2 is the keys column, B3 the properties column, and B4 the corresponding values.

One key with multiple property and value pairs:

=SETPROPERTY(globalvariables.gv_setproperty,"[Product]",B3,B4)

Multiple keys with one property and value pair:

=SETPROPERTY(globalvariables.gv_setproperty,B2,"Property","Value")

Multiple keys with multiple property and value pairs:

=SETPROPERTY(globalvariables.gv_setproperty,B2,B3,B4)

Multiple keys with multiple properties and one value:

=SETPROPERTY(globalvariables.gv_setproperty,B2,B3,"Value")

Editing and deleting properties and values

When SETPROPERTY is used to reference hyperblock cells, these actions are possible:

  • Delete a row from the XML definition
  • Delete a single value
  • Delete multiple properties
  • Update or set a single value
  • Update or set multiple values

Examples

Delete a row from the XML definition:

=SETPROPERTY(globalvariables.gv_setproperty,"Key")

Delete a single value:

=SETPROPERTY(globalvariables.gv_setproperty,"Key","")

Delete multiple properties (for example, delete properties 1 and 3 from a list of properties):
=SETPROPERTY("XML_properties","key","property1","","property3","")

Set a single value:

=SETPROPERTY("XML_properties","key","property","value")

Set multiple values:

=SETPROPERTY("XML_properties","key","property1","value1","property2",
"Value2","Property3","Value3")

Change multiple values with wildcard on key:

This variable has two keys, each with a different value:
<Table><Row name="Key1"><Property name="property" value ="Value1" /></Row>
<Row name="Key2"><Property name="property" value ="Value2" /></Row></Table>
To change both Value1 and Value2 to NewValue:

=SETPROPERTY("XML_properties"," key* ","property","new_value")

The wildcard identifies both keys and the formula changes both their values.

Change multiple values with wildcard on property:

This variable has two keys, each with two properties and values:
<Table><Row name="Key1"><Property name="property1" value ="Value1"/>
<Property name="property2" value ="Value11"/></Row>
<Row name="Key2"><Property name="property1" value ="Value2" />
<Property name="property2" value ="Value21"/></Row></Table>

To change the value of Property1 and Property2 of Key1 use:

=SETPROPERTY("XML_properties","key","property*","new_value")

The wildcard identifies both Property1 and Property2 of Key1.

To change the properties of both keys, use a wildcard on both key and property:

=SETPROPERTY("XML_properties" ,"key*","property*","new_value")