According to the current documentation, we can pass a dataverse record as a parameter. This is still very beneficial for some scenarios. But what if we want to pass a set of parameters without using an existing record.
After several attempts, I managed to pass an object containing some properties from the model driven app to the custom page using the navigateTo method. The next video illustrates this scenario. Indeed, the idea is to pass an object which contains two properties of type text from the MDA to the Custom Page using the navigateTo method.
As you can see, I used the recordId parameter to pass my JSON object. According to the documentation for the navigateTo method, the recordId parameter is optional and expects to be passed a GUID parameter.
Fortunately for us, Microsoft does not check if we pass a GUID or not, the API expects a string. Using this behavior, we can pass a JSON using this parameter.
In my opinion, this is still a bug, it is better to add validation for this type of parameter and give us the possibility to pass an object using a “data” parameter as for a normal webresource.
as indicated in the documentation of the navigateTo method for the “custom” type, we can retrieve the recordId parameter using the Param(“recordId”) function. As we have passed a JSON instead of a GUID, we will have to parse this JSON to extract the values of the different properties.
Set(inputParameters,JSON(Param("recordId"))); Set(props, Match(inputParameters, "\""prop1"":""(?<prop1>[^""]*)"",""prop2"":""(?<prop2>[^""]*)"))
Then I can use the values extracted from the JSON. In my case, I used a simple concatenation:
Concatenate("Props from MDA 🤓", props.prop1, " ", props.prop2)
Hope it helps…