DisplayWithVariables lets you open a Turnkey ViewModel from a URL and assign URL-supplied values to string variables in that ViewModel; use it when an external link, callback, or another application must control the initial state of a view.
What DisplayWithVariables does
When Turnkey receives a DisplayWithVariables URL, it navigates to the requested ViewModel and looks for variables whose names are supplied as URL parameters. If a matching string variable exists, Turnkey assigns the parameter value to that variable.
For example, if the ViewModel SomeView contains a string variable named vNewVar1, this URL opens the view and assigns value1 to that variable:
http://<Host>/Turnkey/DisplayWithVariables?view=SomeView&id=2!28&vNewVar1=value1
The variable name is the URL parameter name. A parameter named vNewVar1 is therefore matched against the ViewModel variable named vNewVar1.
Prepare the target ViewModel
Before creating the link, make sure the target ViewModel has the variables that the URL will supply.
- Open the target ViewModel in MDriven Designer.
- Add a variable with the exact name expected in the URL. For example, add the string variable
vNewVar1. - Use that variable in the view's modeled logic or display as required.
- Publish or deploy the updated application before using the URL.
If the URL contains vNewVar1=value1, but the target ViewModel has no string variable named vNewVar1, no value is assigned for that parameter.
Choose a URL format
| Format | Use | Example |
|---|---|---|
| DisplayWithVariables | The original, explicit endpoint. Both view and id are required in this form.
|
http://<Host>/Turnkey/DisplayWithVariables?view=SomeView&id=2!28&vNewVar1=value1
|
| DWV query form | The short form of DisplayWithVariables. Use v for the ViewModel name and i for the root-object ID.
|
http://<Host>/DWV?v=SomeView&i=2!28&vNewVar1=value1
|
| DWV path form | A parameter-free callback-friendly form for the view name and root-object ID. Variable values can still be supplied as URL parameters when needed. | https://<server>/DWV/SomeView/2!28
|
Use the DWV shortcut
The DWV endpoint is a shortcut for DisplayWithVariables.
- Replace
viewwithv. - Replace
idwithi. - Keep each ViewModel variable assignment as its own parameter.
For example, this original URL:
http://<Host>/Turnkey/DisplayWithVariables?view=SomeView&id=2!28&vNewVar1=value1&vNewVar2=value2
can be written as:
http://<Host>/DWV?v=SomeView&i=2!28&vNewVar1=value1&vNewVar2=value2
Open a view without a root object
In the DWV query form, omit i when no root object should be sent. Turnkey then assumes a null root-object ID.
http://<Host>/DWV?v=SomeView&vNewVar1=value1
This differs from the original DisplayWithVariables form, where id is required.
Use DWV for callback URLs
Some external services cannot accept callback URLs that contain parameters. For these cases, use the DWV path form:
https://<server>/DWV/SomeView/2!28
This form has the same navigation intent as these earlier forms:
https://<server>/Turnkey/AngularApp#/SomeView/2!28
https://<server>/DWV?v=SomeView&i=2!28
Use the path form when the receiving service requires the callback path to avoid query-string parameters.
Read the incoming URL in modeled code
DisplayWithVariables and DWV set the ViewModel variable RawURL to the requested URL, including its parameters. You can use RawURL in modeled code when the application needs special handling based on the incoming request.
For example, a ViewModel opened through a callback can inspect RawURL to distinguish that request from ordinary navigation and apply callback-specific modeled processing.
Root-object IDs
The examples use a root-object ID such as 2!28. If a link must remain valid across contexts where that form of ID is not suitable, review the ExternalId guidance for the more time-resilient <classid>!GP!<guid> form.
Checklist
- Use the exact ViewModel name in
view,v, or the DWV path. - Create a matching string variable for every value you expect to inject.
- Use the original endpoint only when you can provide both
viewandid. - Omit
ionly with the DWV query form when a null root object is intended. - Use
/DWV/<ViewName>/<RootId>when a callback provider cannot handle URL parameters.
