2

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?

2 Answers 2

3

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, 2021 at 17:32
-1

Try the steps in this video for showing a field conditionally depending on whether you are creating a list item OR viewing/editing a list item https://youtu.be/lxAmYT-uQe4?feature=shared

Steps:

  1. Create a conditional text column. This column must have a default value.
  2. Create the column that must conditionally appear depending on whether a user is creating and item OR viewing/editing an item. 3.Click on the NEW button.
  3. Click on EDIT COLUMNS.
  4. Untick the conditional column in order to HIDE it.
  5. Click on the 3 dots next the column that must conditionally SHOW.
  6. Click on EDIT CONDITIONAL FORMULA
  7. Add the formula "=if([$Title] == '', 'false', 'true')" where Title is the name of your conditional column.
  8. Click Save and Save.
1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Nov 23, 2023 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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