Notifications
Clear all

[Solved] Why should I use ModelLink instead of just autocomplete component?

3 Posts
2 Users
0 Reactions
1,176 Views
0
Topic starter

I'm adding new report or custom screen and don't know what type of the field (filter, retrieval or just regular screen field) to use in order to select a model (multiple models). What should I use ModelLink or Autocomplete?

1 Answer
0
Topic starter

Use One.form.ModelLinkField (xtype: 'modellinkfield') for screens or MODEL_LINK field type in reports.
It makes user experiences seamless across all UI and gives ability to:

  • select multiple models in picker
  • search with wild-card
  • force user to select a value from picker/autocomplete or just give a wild card

Please check short example below for a report, where both wild-card and exact user selection are supported. Single sql-based report is used for user selection in picker and autocomplete. In retrieval section duet o model link field type usage platform will automatically generate a registered drill down link from report to user details.

<Report>
  <Name>SearchUsers</Name>
  <SqlDef Name="SearchUsers" GroupName="Reports"><![CDATA[
  select sys_user_id, user_name from users 
  where ${filterIfNotNull:SYS_USER_ID,sys_user_id in $SYS_USER_ID$}
    and ${filterIfNotNull:USER_NAME,${reverseUpperLeadingWildcard:user_name,$USER_NAME$}}
  ]]></SqlDef>
  <Filters>
      <CustomFilterField>
        <FieldRef levelType="Undefined" category="MODEL_LINK">
          <ModelLinkTargetLevelType>User</ModelLinkTargetLevelType>
          <FieldName>UserName</FieldName>
        </FieldRef>
        <Type>MODEL_LINK</Type>
        <ModelLinkHandling>
          <CustomModelName/>
          <PickerReportDefName>OMS.UserPickerReport</PickerReportDefName>
          <AutocompleteReportBased>true</AutocompleteReportBased>
        </ModelLinkHandling>
        <ModelLinkMapping exactMode="false" surrogateIdSqlName="SYS_USER_ID" displayFieldSqlName="USER_NAME" multiSelectMode="false"/>
      </CustomFilterField>
    </Filters>
  <Retrievals>
    <CustomRetrievalField>
      <FieldRef levelType="User" category="PDF">
        <ModelLinkTargetLevelType>User</ModelLinkTargetLevelType>
        <FieldName>Name</FieldName>
      </FieldRef>
      <Type>MODEL_LINK</Type>
      <ModelLinkMapping surrogateIdSqlName="SYS_USER_ID" displayFieldSqlName="USER_NAME"/>
    </CustomRetrievalField>
  </Retrievals>
</Report>
GregMerrill 2015-09-07 09:09:00

Another point to add - autocomplete was implemented before we even had full support for the model link field. That's part of the reason why the field exists at all. Now that we have the model link field, it is very rare that you ever need the autocomplete field.

Sergey Soshnikov Topic starter 2015-09-07 09:09:00

Yes, there is a historical reason for that that's why developers must use model pickers instead of copy/pasting old reports with autocompletes.