A few weeks ago I looked at calling flows from model driven apps. And for a while my flow worked as expected and then suddenly it broke with an “Expected String but got Null” message
Calling a flow from a Model driven app
When you call a flow from a model driven app you would normally expect to see a dialog with a Run flow button.
In the past this worked as expected but recently I got the Something went wrong. please refresh the page or try again after some time.
Well, you can wait for a while, but this isn’t going to fix itself.
As you scroll down the dialog you will find the details of the error. in my case i got :
Error: The input body for the trigger ‘manual’ of type Request did not match its schema definition. Error details: ‘Invalid type. Expected String but got Null , invalid type Expected String but got Null
That still doesn’t mean very much!
Something is wrong with he trigger and something is wrong with the data in the trigger.
ok, what should we do to fix this issue.
Expected String but got Null workaround
Hopefully Microsoft will fix the real issue soon, but in the meanwhile I fot a good workaround. Hopefully this will help some other people. As it can be very painful when you run into this issue. It will simply be impossible to run the flows from your Model driven app without getting the Expected String but got Null.
My flow start with a When a record is selected trigger.
Then in the rest of the flow I was using information returned by this trigger. These references to the trigger are the causes of the problem.
So we have to avoid those. There is however one field that we can reference and that is the opportunity id. Any other properties that we reference might mean that the schema ( the shape of the data that is sent between the Model-driven app and the flow) might change. You adding another reference to a different field may change this schema.
To avoid this, we can use a get a record action.
In the get a record action we reference the opportunity. and now in any of the following steps we can only use dynamics data from this Get a record action rather than from the trigger.
Both the trigger and the get a record action will return exactly the same data anyway. So other than one maybe unnecessary extra call to the database, there isn’t too much of a disadvantage of using this method.