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?
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:
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>
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.
Yes, there is a historical reason for that that's why developers must use model pickers instead of copy/pasting old reports with autocompletes.