0

I am using JSON to configure the layout of my list form. All is working well except that I would like to conditionally set the style of an object based on whether this is a NEW or EDIT form. My first thought was inspect the Created, ID, or Author.title fields and if they existed, assume this is an EDIT operation. However, I can never get them to return any data.

It does not matter if I am editing a record or opening a new entry, the following line always results in "0, 0, 0":

"txtContent": "=length([$ID]) + ', ' + length([$Created]) + ', ' + length([$Author.title])"

What mechanism can I use to determine if the current form is displaying a blank form for new entry or a populated form for editing an existing record?

1

Using Created, ID, or Author in JSON code will not work as those fields are not shown on list forms.

You can refer only those columns which are shown on list forms.

Also, even if you refer any other column in JSON, it will only work as expected until you start entering value in column.

Example:

I am using Title column to check if the list form is New form or Edit/Display form like below:

{
  "elmType": "div",
  "txtContent": "=if([$Title], 'Edit/View Form', 'New Form')"
}

New Form:

Output - Before entering value:

enter image description here

Works as expected.

Output - After entering value:

Once I start entering value, condition in above if will satisfy and form will start showing as Edit/View Form.

enter image description here


So, I don't think there is any way to check if the current list form is New form or Edit form using JSON.

Documentation: Configure the list form

1
  • That is what observed as well. It is unfortunate that is the case as it seems to be a useful feature to be able to differentiate between edit modes.
    – Shawn
    Mar 30 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.