Selecting an eventid from a list of records

From SmartWiki
Jump to: navigation, search

In the following example, we will imagine that:

  • We want to have a dropdown field that shows a list of Payments attached to a record that are in Scheduled status.
  • Additionally, we want to display some information about the Payments so that the user can differentiate between them, and select the appropriate record.
  • The list of Payments in the dropdown should be automatically populated, depending on the record that the field appears on.

This example shows a dropdown on a record with two Payments in the Scheduled status.
DropDownExampleUsingListSyntax.png

The field above:

  • is a Select One - Combo Box custom field;
  • has a field name of Payment List;
  • has a field caption of List of Payments that can be assigned to the report; and
  • has the following in the Values section of its field options:
--Please Select--;@parent.[#(?object=activity;criteria=typename='Payment' and statusname='Scheduled';)~eventid~=Payment on $Scheduled Payment Date$ of $Payment Amount$;#]@

Breakdown of List Syntax

The variable above uses SmartSimple's List Syntax. The following is a breakdown of the different components of the syntax used, working from the inside out.

Syntax Description
VariableExampleStoreDisplay.png
  • This is an example of the use of stored values/display values.
  • The value on the right of the equals sign, Payment on $Scheduled Payment Date$ of $Payment Amount$, is the option that will be displayed on the dropdown list. The words between dollar signs ($) are variable names referring to the two fields, Scheduled Payment Date and Payment Amount.
  • The value on the left, ~eventid~ is a variable that will return the unique ID of the selected record and that is what will be saved to the database.
VariableExampleObjectandCriteria.png
  • ?object=activity tells the system that the list to be returned will be a list of Level 2 records. See List Syntax for the list of objectnames that can be substituted for activity.
  • criteria=typename='Payment' tells the system that it should only return the Level 2 records that are of the type Payment.
  • statusname='Scheduled' tells the system that it should also only return the records that are in the Scheduled status.
VariableExampleBracketHash.png
  • The [#...#] tags tell the system that it should process a list of objects.
  • Everything between the [#...#] tags will be repeated as many times as there are records that meet the criteria specified above.
VariableExampleParent.png
  • The @parent...@ syntax tells the system that it should look at the parent record for the list of records to be returned.
VariableExample-PleaseSelect.png
  • For combo boxes, the values that are displayed are separated by semicolons.
  • The --Please Select--; will be the first value, followed by what is returned by @parent.[#...#]@.
  • Given that there is a semicolon contained within the list brackets ([#...#]), each value from the returned list will be followed by a semicolon as follows:
    --Select One--;Payment 1;Payment 2;...;Payment N;

Now that we have a stored list of eventids, we can refer to this field's stored value to perform operations on the selected records. For example, workflows can be triggered against these records.

Additional examples of the objects and criteria that can be selected are available on the List Syntax page.