List form Configure layout with a conditional "txtContent" issues

Copper Contributor

I am using the following txtContent in the Header section of the form layout:

 

 

 

 

"txtContent": "=if ([$Title] == '', 'New Record', 'Patient: ' + [$Title])"

 

 

 

 

In edit mode (item edit) it works but when I am adding a new Item, I get the following error message:

Failure: Title was not found on the data object.

 

What are the causes of this error?

 

UPDATE:

 

Sorry for not providing the full Header code. Just figured out that the reason for that error message was "debugMode": true:

 

 

{
    "debugMode": true,
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },

 

 I have changed it to "debugMode": false and it works now for a new item as well.

3 Replies

@Leon Kuper 

 

debugMode is an optional property that is meant for debugging. It outputs error messages and logs warnings to the console. 

So, you only use this while you are playing with JSON and checking this is anything wrong with your JSON code.

So, if JSON code is working fine now, you can remove the debugMode property from JSON instead of setting it to false, like:

 

 

{
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },

 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Yes, you are right about debug mode. But why it throws the error when everything should work? A New item logic only caused this error message. There is definitely something wrong in debugging logic. How can I be sure that everything is fine when debug throws errors it is counterintuitive at least to me. But anyway, it works now.

@Leon Kuper 

 

This is because there is no value in "Title" column when you open a new form. Try entering some value in Title field on new form and error will disappear immediately.

 

I agree this should be handled automatically on new form (I will create a new issue for this). But for now you can remove debugMode from JSON. IMO, we should not use debugMode/debugger in production environment after development is completed.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.