Function Parameters

Setting Default and Test Values

The purpose of setting default values differs from that of setting test values; however, the steps are the same.

A parameter can often have one or more reasonable values that the user is likely to set the parameter to when using the function. Instead of requiring the user to necessarily set the parameter before using the function, you can set the most likely value for him or her by default, sparing him or her a few clicks in the GUI and thus making the function more user-friendly and usable.

Setting a test value has no effect on the function when the user inserts it in the content; however, it helps debug the function when you are creating it.

To create a default or test value:

  1. On the Input parameters tab, select the parameter and click in the Default (or Test) value field.
  2. In the Parameter Default (or Test) value window in the Value field, enter a value.
  3. Click OK.

Figure 1: Setting the default value

To delete a default or test value:

  1. On the Input parameters tab, select the parameter and click in the Default (or Test) value field.
  2. In the Parameter Default (or Test) value window, click Advanced View.
  3. Select the function that handles the value (for example, Composite.Constant.Integer) and click Delete.
  4. Click OK.

Using Constants

For simple values, C1 CMS uses one of the matching Constant functions behind-the-scenes:

  • Composite.Constant.Boolean
  • Composite.Constant.DateTime
  • Composite.Constant.Decimal
  • Composite.Constant.Guid
  • Composite.Constant.Integer
  • Composite.Constant.String
  • Composite.Constant.XhtmlDocument

You can see what function is used for the parameter by switching to the Advanced View.

Figure 2: A Constant function in use

Using GetInputParameter

You can use a value from one input parameter in another input parameter by calling the Composite.Utils.GetInputParameter function. The function has one required parameter:

  • Parameter name (InputParameterName): The name of the parameter the value of which you want to use in this parameter.

Using ParseStringToObject

You can specify a string for the input parameter of a specific type (for example, DateTime) and have C1 CMS parse it for you into the corresponding object (DateTime, in the example) - by using Composite.Utils.ParseStringToObject function. The type of the object depends on the input parameter type.

The function has one required parameter:

  • String to parse (StringToParse): The string formatted in a way that can be converted into the type of the expected object.