ModelLink Mappings

A frequent requirement for reports is to provide links to the detail page for a model. For example, earlier in the tutorial we built a Book detail page - let's convert the Book "Title" field into a ModelLink retrieval field so we can link to that page.

To show a model link in the retrieval, we need to provide the level type of the model in question, its surrogate id, and a display field. First, we add the surrogate id to the select clause:

select SYS_BOOK_ID, TITLE, ...
from ZBKS_BOOK

Next, we set the "levelType" attribute of the retrieval field to ZBKS.Book, we set the Type to MODEL_LINK, and we replace the SimpleMapping with a ModelLinkMapping which identifies the surrogate id and display field columns from the SQL result:

<CustomRetrievalField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>Title</FieldName>
</FieldRef>
<Type>MODEL_LINK</Type>
<ModelLinkMapping surrogateIdSqlName="SYS_BOOK_ID" displayFieldSqlName="TITLE"/>
</CustomRetrievalField>

Once completed, your Title field should be enabled as a model link:

images/download/attachments/144836747/retrieveModelLink-version-1-modificationdate-1655932077000-api-v2.jpg