Expected String but got Null,

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.

Expected String but got Null, when calling a flow from a Model Driven app Microsoft Office 365 image 21

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.

Expected String but got Null, when calling a flow from a Model Driven app Microsoft Office 365 somethign went wrong. Please refresh the page or try agains 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

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.

Expected String but got Null, when calling a flow from a Model Driven app Microsoft Office 365 image 23

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.

Expected String but got Null, when calling a flow from a Model Driven app Microsoft Office 365 image 24

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.

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

5 thoughts on “Expected String but got Null, when calling a flow from a Model Driven app”
  1. Hi Pieter,
    I encountered the same issue today. But strangely my flow was somethimes working and sometimes giving the error you mentioned.

    When inspecting the trigger with ‘peek code’ it showed two field that it is using further down in the flow. So it looks like a automatic ‘rollup’ of all fields that are used.
    Unfortunatiely the fields are flagged as ‘required’

    So that is why my flow sometimes works. As long as all field are filled, it works. I like it this way, because I need both fields.
    If one of them is optional, your workaround is great.

    1. Most likely the sometimes working is down to the actual values in the data. When fields are not supplied they will be set to null and therefor without a datatype

  2. Would be great if Microsoft came up with a holistic solution to null fields – real pain to always check for null! Often use many ‘not required’ fields and checking them everytime for null to avoid unsuccessul flows down the line is a constant issue 😦 that folk seem to run into

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.