Sometimes when configuring a parameter for a view, you may also need or want to have a parameter value pre-selected as a default value for users. The default value is a path expression that should result in a single value. This article provides simple examples of how to set a default value for a parameter in a configured view, e.g., report, graph, grid, etc. Setting a default value is optional. 


There are two options for setting a pre-selected value: hintContextPath and defaultValue. They can be used in the same view configuration for different parameters, but cannot be combined/used together for the same parameter.


hintContextPath

The optional hintContectPath attribute can hold a list of part SIDs (ASID1;ASID2;...) that will define a default selection of an item in the current structure tree. The list works in the same way as paths in the tag <ForEachPathReference>.

(Since a common use of parameters is to select a specific context, any such context available in the structure tree is a more likely choice than some arbitrary context.)


Example Configuration 

Below is a simple graph example using hintContextPath.

<Graph>
    <Parameters>
        <Parameter caption="Functions" name="Baseline" hintContextPath="FUPA;REDC">
            <Values>
                <ForEachPathReference path="FUPA;REDC">
                    <AddValue/>
                </ForEachPathReference>
            </Values>
        </Parameter>
    </Parameters>
</Graph>


Example Result 


defaultValue 

In a similar way, the optional defaultValue attribute can be used to define a default selection.  The supported data types are: 

  • Boolean
  • String
  • Date
  • Integer
  • Int64
  • User
  • Object


The provided default value must be a valid parameter value, otherwise the default value will be empty.


Example Configuration 

Below is a configurable graph example demonstrating default values for Boolean, String, Date, Integer, Int64, and Object. Note that the last Parameter uses the hithContextPath option instead to demonstrate that you can use both options in the same configuration.

<Graph>
	<Parameters>
		<Parameter caption="Boolean" name="Boolean" as="Boolean" defaultValue="true">
			<Values>
				<ForEach select="[true, false]">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="String" name="String" as="String" defaultValue="'String1'">
			<Values>
				<ForEach select="['String1', 'String2']">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="Date" name="Date" as="Date" defaultValue="CreationDate.Format('')">
			<Values>
				<ForEach select="[CreationDate.Format('')]">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="Integer" name="Integer" as="Integer" defaultValue="1">
			<Values>
				<ForEach select="[1, 2, 3]">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="Int64" name="Int64" as="Int64" defaultValue="-1">
			<Values>
				<ForEach select="[-1, 2, -3]">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="Object" name="Object" as="Object" defaultValue="HomeLibrary">
			<Values>
				<ForEach select="HomeLibrary">
					<AddValue/>
				</ForEach>
			</Values>
		</Parameter>
		<Parameter caption="Functions" name="Baseline" hintContextPath="FUPA">
			<Values>
				<ForEachPathReference path="FUPA">
					<AddValue/>
				</ForEachPathReference>
			</Values>
		</Parameter>
	</Parameters>
	<Node/>
</Graph>


Example Result