Login    Sites MenuBlueStep

BlueStep Platform Support

RelateScript
Outline full outline 
Overview 
Data Types 
Operators 
Statements 
Functions 
Working with Relate Data 
Field Data 
Text Fields 
Memo Fields 
Date/Time Fields 
Number Fields 
Boolean Fields 
Single Select Fields 
Multiple Select Fields 
Signature Fields 
Document Fields 
Relationship Fields 
Biometric Fields 
Password Fields 
Accessing Forms and Fields 
Special Data and Functions 
How Formulas Work 
Related Topics 

Relationship fields are represented using a custom data type. A Relationship field value is never null; however, it may be empty. This condition can be determined via its custom fields. A Relationship field value has four fields and three custom functions detailed below.

Field/Method Name Return Value Description
options RelationshipItem[int] The options field is an Array value containing the list of currently valid options which may be selected. It is an Array of RelationshipItem indexed by Integer values. The first RelationshipItem is at index 0.  RelationshipItem is another custom type or Object type. It is described below.
selected RelationshipItem[int] The selected field is an Array value containing the list options that are currently selected.  This field is of the same type as the options field, but contains a different list of options.  Note, that the currently selected values may not be currently valid, and therefore may not be in the options list.  WARNING:  The order of the items in this collection are semi-random and can change mid-formula in very unpredictable ways.  When looping through this list it is always advisable to copy the list into a separate variable before the loop, then loop on and lookup items from the copy.  Copying the list into a separate variable is required if there is any chance that the list of selected items might be altered during looping.  This warning can be safely ignored if using a two-loop-variable for/in loop.
original RelationshipItem[int] The original field is an Array value containing the list options that were selected at the beginning of the current edit.  This field is of the same type as the options field, but contains a different list of options.  Note, that the formerly selected values may not be currently valid, and therefore may not be in the options list.  Also, the originally selected items may or may not be currently selected.
changed RelationshipItem[int] The changed field is an Array value containing the list of options have become newly selected or unselected as part of the current edit.  This field is of the same type as the options field, but contains a different list of options.  Note, that the changed values will usually be in either the selected or original option lists, but those list also contain options that have not been changed.  Namely, options which are in both the selected and original lists, will probably not be in the changed list...that is unless they have been deselected then reselected.  A similar condition can occur for options that have been selected then deselected.  WARNING:  The order of the items in this collection are semi-random and can change mid-formula in very unpredictable ways.  When looping through this list it is always advisable to copy the list into a separate variable before the loop, then loop on and lookup items from the copy.  Copying the list into a separate variable is required if there is any chance that the list of changed items might be altered during looping.  This warning can be safely ignored if using a two-loop-variable for/in loop.
isValid Bool This is a boolean property which indicates whether the current entry is valid to be a part of a relationship.  If the current entry is not valid, then 'options' will always be empty since there will be no entries which can form a fully valid relationship with this record.
set(String id[, Bool select]) Bool This function sets or clears the relationship to another entry, given the id of the entry.  It is only available when the relationship field is editable.  It is primarily intended to be used in converting from a 'params' type field to a Relationship field.  The function receives one required parameter, the id of the related entry.  It also may receive an optional boolean value which indicates whether the entry should become selected or deselected with the default being true, or selected.  The result of this function is a boolean value indicating one of three things:  A value of true means a change was successful; a value of false means it was unsuccessful because, for instance, the id doesn't belong to the target form; a value of null means there is a configuration problem such as set(...) being called on an empty object.
isSelected(String id) Bool This function checks if entry is selected, given the id of the entry.  The result of this function is a boolean value indicating one of three things:  A value of true means the id is selected; a value of false means it is not selected; a value of null means there is a configuration problem such as isSelected(...) being called on an empty object or the id is not a potential selection.
get(String id) RelationshipItem This function gets a RelationshipItem object for the current field, given the id of a potentially selectable entry.  It is roughly equivalent to the getById(...) function of queries and reports.  The function receives one additional required parameter, the id of the related entry.

 

The RelationshipItem Custom Data Type
The RelationshipItem custom data type represents one of the available options relationship field.  It has 9 fields which can be used to discover its value and make it the selected option, or one of the selected options in the case of a multi-select field.

Field/Method Name Return Value Description
id String A read-only String value containing the system assigned id of the related form entry.
fqId String A read-only String value containing the fully qualified system assigned id of the related form entry.
shortId String A read-only String value containing the short id of the related form entry.
name String A read-only String value containing the value in the display field of the related form entry.
recordName String A read-only String value containing the name of the record that the related form entry belongs to.
recordTypeFormId String A read-only String value containing the id of the main form from the record that the related form entry belongs to.
isSelected Bool A Boolean value indicating whether this particular entry is currently selected as a being related.  This value is read-only if the relationship field is read-only.  It is settable when the relationship field is editable.
wasSelected Bool A read-only Boolean value indicating whether the entry was selected at the beginning of the edit.
isValid Bool A read-only Boolean value indicating whether the entry currently meets the criteria for a valid selection.  Existing selections which were valid at the time they were selected may not be valid later, for instance if there is a condition based on the current date which automatically expires old entries.
isDeleted Bool A read-only Boolean value indicating whether the entry has been deleted as part of the current operation.  The data from the deleted entry is temporarily retained in memory so that it may be referenced during the remainder of the operation even though the entry is removed from the permanent data store.
isChanged Bool A read-only Boolean value indicating whether the entry has been selected or deselected as part of the current edit.  Note this field will continue to be true, even if the 'isSelected' value is returned to its original state.
entry RelateEntry A custom object field which contains the actual form entry from the related form.  It will have all of the properties of the related form including access to all fields of the related form (assuming a formula id was defined for each field during form configuration).  The entry will be editable if the currently relationship field is editable and if the current formula is not a pre-edit or field formula.  Accessing this value will create a dependency on the related form thus preventing deletion of the form (but not any of its entries).