Defining selectRecordWithCondition Functions

Learn about selectRecordWithCondition Functions.

Below is the full structure of the record select object.

selectRecord({ 
  from: { 
    filter: "", 
    filterFields: {}, 
    fixedFilterName: "",
    sourceCopyFieldGroupName: "", 
    infoAreaId: "", 
    infoAreaIds: [], 
    link: { 
      infoAreaId: "", 
      recordId:"", 
      linkId: 0 
  }, 
  relationName: ""  
  searchAndListName: "", 
  searchContext: { 
    items: [] 
  },
  selectionMode: "", 
  showFilters: false, 
  useAutoSearch: true 
  } 
 target: { 
  addLink: true,
  copyFields: {}, 
  freeInput: true, 
  infoAreaId: "", 
  links: [] 
 } 
});

Many properties are optional or only work in certain combinations. Please refer to the parameters sections below for details:

from / object

This parameter is mandatory, and sets the SearchView and its behaviour up. It contains one or more of the subsequent properties.

selectRecord({ from: {} });

infoAreaId / string

This property (only) is mandatory and defines the info area to select records from. If the property 'searchAndListName' (see below) is not set, it is used for getting the SearchAndList-Configuration.

selectRecord({ from: { ... infoAreaId: "FI", ... } });

infoAreaIds / string[]

This property can be used to define multiple InfoAreas to select records from. Alternatively, the property 'infoAreaId' can be used the same way. Depending on the number of info areas, the user is able to select the info area from a context menu or from a popup list (if >5 info areas). After the user selected the info area, the corresponding search is shown.

selectRecord({ from: { ... infoAreaIds: [ // the user is asked to select between a company and a person to select "FI", "KP" ], ... } });

infoAreas / object[]

Similar to infoAreaIds this property can be used to define multiple info areas to select records from. However, this property allows users to specify the name of a special Search&List configuration to be used by the record selector.

selectRecord({ from: { ... infoAreas: [ // the user is asked to select between a company, a person and a ticket { infoAreaId: "FI", searchAndListName: "MySpecialCompanySearch" }, { infoAreaId: "KP", searchAndListName: "MySpecialPersonSearch" }, { infoAreaId: "KM" }, "PR" ], …... } });

link / object

Defines the parent record. If set, only records linked to this record can be selected.

selectRecord({ from: { ... link: { // Only records linked with linkId '0' to the record defined in 'recordId' of infoArea 'FI' can be selected infoAreaId: "FI", recordId: "0x0123456789876543", linkId: 0 }, ... } });

searchAndListName / string

The name of the SearchAndList-Configuration (as defined in update CRMesigner) to use for the selection.

selectRecord({ from: { ... searchAndListName: "KPSub", ... } });
Note: If not set, the above property 'infoAreaId' is used for retrieving a configuration.

filterFields / dictionary

This parameter defines:
  • which fields of the search form should be prefilled
  • where do the values used for prefilling come from
  • whether the user is allowed to change those fields
This is accomplished by defining the target field by its name or ID and assigning it a value. This value could be another fieldname or -number, which means that the content of this field in the source (e.g. the Expand View) is copied to the desired field in the target, the Search View.

Alternatively, instead of another fieldname or number, there is the possibility to apply a more complex object, telling the RecordSelector if e.g. a fixed text is used to prefill, or the content of a linked field.

selectRecord({ from: { ... filterFields: {

1: 2, // The value of the field with number '2' is copied from the ExpandView to field '1' in the SearchView

2: "FieldName", // The value of the field with name 'FieldName' is copied from the ExpandView to field '2' in the SearchView

FieldName1: "3", // The value of the field with number '3' ('''Note''': it is also possible to write field-number as strings) is copied // from the ExpandView to field 'FieldName1' in the SearchView

FieldName2: "FieldName", // The value of the field with name 'FieldName' is copied from the ExpandView to field // 'FieldName2' in the SearchView

FieldName3:{ // The text 'FixedText' is copied to field 'FieldName3' and set readonly

value: "FixedText", // The text to copy

isFixed: true // If true, the user cannot edit this field in the SearchForm

},

4: { // The field 'FieldName' of the ExpandView is copied to field '4' of the SearchView and set readonly

source: "target", // The field is copied from source 'target', what is (mostly) the ExpandView

fieldId: "FieldName", // The name or number of the field to copy.

// (note: you can also use the dot notation to specify linked field ids

// eg: FI.2 or FI.Company. Note that this linked field must be on the expand form which the field is read)

isFixed: true,

compareOperator: "=" // The operator used to identify which field in the search control receives the value.

// A field with this fieldId and operator must already exist in the search control used by the selector,

// except for the equals operator. if not specified, the "=" is used. Equals operator matchs against

// either a fieldId with no operator or a fieldId with "=" operator in the search control.

} // '''Note''': If property 'value' is not set, 'source' and 'fieldId' are mandatory!

"FreeC2": { source: "target", fieldId: "FI#2.Company" } // The Company field from the second FI record associated with the current record

// has its Company field contents set in the FreeC2 search field.

// The number after the # is the link id.

}, ... });

8.2 The filter values in filterFields now overrides the values remembered from a previous search. To disable this behavior you can set property important to false.

selectRecord({ ... filterFields: { "FreeD1": { fieldId: "Revenue", important: false } } ...

searchContext / object

If a search context is provided, users of update.CRM web can select whether they want to search the whole database or only in the current context. Searching in the current context only returns results that are linked to a link record of the current record. If configured accordingly, users get a drop-down list in the search form where they can select the context (in which the last item of this list is always the entry to be selected first).

selectRecord({ from: {

searchContext: { items: [ "FI", // show only records linked to the company (using the default link)

{ infoAreaId: "KP", linkId: 2 }, // show only records linked to the person linked with linkId 2.

{ parentInfoAreaId: "KP", infoAreaId: "FI" }, // show only records linked to the company going over the indirect person link

null // show records from the entire database

] } ... } });
Note: the special setting of parentInfoAreaId can be used if there is no direct link in the context for the desired info area, but it can be retrieved as a link of the linked record.

selectionMode / string

Defines how records can be selected. Possible values are:
  • Single: Select a single record, close the Search popup afterwards, and continue with copying values, if specified.
  • Multi: Select one ore more records, close the Search popup afterwards, and continue with copying values, if specified.

selectRecord({ from: { ... selectionMode: "single", ... } });

useAutoSearch / Boolean

If set to true, the search starts immediatly after the Search View is completely created.

Default value is false.

selectRecord({ from: { ... useAutoSearch: true, ... } });

showFilters / boolean

If set to false, there is no possibility to define and/or use filters in the Search View.

Default value is true.

selectRecord({ from: { ... showFilters: false, ... } });

filter / string

Pre-sets a filter in the Search View, but as a 'suggestion' which can be changed by the user.

selectRecord({ from: { ... filter: "FI.MyCompanyFilter", // The name as defined in designer or web ... } });

fixedFilterName / string

Presets a filter to the Search View which cannot be changed by the user.

selectRecord({ from: { ... fixedFilterName: "FI.MyCompanyFilter", // The name as defined in designer or web ... } });

sourceCopyFieldGroupName / string

Defines the Field Group from which the List control is used for determining which fields to read from the target record to create additional filter parameter values.

selectRecord({ from: { ... sourceCopyFieldGroupName: "FI.MyCompanyFieldGroup", ... } });

relationName / string

Defines the relation to another record. Used with parameter 'link'. TODO

selectRecord({ 
  from: { 
   ...  
   relationName: "$Parent" 
   ... 
  } 
});

target / object

This parameter is optional and defines how the selected record(s) is/are treated. It contains one ore more of the subsequent (optional) properties.

selectRecord({ 
   from: { 
     ... 
   }, 
   target: { 
     ... 
   } 
});

infoAreaId / string

Defines the info area of the record currently active in the Expand View.

Note: Do not set infoAreaId for selectors defined for link fields! Setting infoAreaId on target tells the selector engine to ignore the link of the field for which the the selector is defined. As a consequence the record reference string is not copied into the target field.
selectRecord({ 
   from: { 
     ... 
   }, 
   target: { 
     ... 
     infoAreaId: "KP", 
     ... 
   } 
});

copyFields / dictionary

Defines which fields of the selected record(s) are copied to the ExpandView.

The syntax and definition is quite similar to the property 'filterFields' of parameter 'from', except 'copyFields' does not support 'complex' definitions.

selectRecord({
  from: {
   ...
  },
  target: {
   ...
   copyFields: {
     1: 1, // The value of the field '1' of the selected record is copied to field '1' in the Expand View
     2: "FieldName", // The value of the field 'FieldName' of the selected record is copied to field '2' in the Expand View
     3: "$Reference", // The value of the evaluated reference text of the selected record will be copied to field '3' in the Expand View
     FieldName1: "3", // The value of the field '3' ('''Note''': Again, field-numbers can also be strings!) of the selected record
                // is copied to field 'FieldName1' in the Expand View
     FieldName2: "FieldName", // The value of the field 'FieldName' of the selected record is copied to field 'FieldName2' in the Expand View 
     FieldName3: "$Reference", // The value of the evaluated reference text of the selected record will be copied to field 'FieldName3' in the Expand View
     4: { value: "your value" }, // The 'value' property will be copied to the field '4' in the Expand View FieldName4: { value: "your value" }, // ...
}, ... }
});

copyInfoAreaFields / dictionary

Provides the ability to define info area related copyFields. Usually you need this if you have defined multiple infoAreaIds (or infoAreas) in from.

selectRecord({
   from: {
     ...
   },
   target: {
     ...
     copyInfoAreaFields: {
      PE: {
       // same object notation as for 'copyFields'
    },
    CP: {
     // same object notation as for 'copyFields'
    }
  },
  ...
 }
});

target / object