Beginner May 2, 2026 · 5 min read

In Frappe 15, depends_on is used to set conditional visibility and behavior for fields based on other field values or expressions. Below is a list of common conditional statements you can use with the depends_on property in your JSON or Python customizations.

Common depends_on Conditions

1. Field Value Equals

Show a field only when another field has a specific value.

"depends_on": "eval:doc.status == 'Open'"

Example: Display the field only if the status field is set to Open.

2. Field Value is Not Empty

Show a field if another field is not empty.

"depends_on": "eval:!!doc.customer"

Example: Display the field if the customer field is filled.

3. Field Value is Empty

Show a field if another field is empty.

"depends_on": "eval:!doc.project"

Example: Display the field if the project field is empty.

4. Multiple Conditions with AND

Show a field if multiple conditions are true.

"depends_on": "eval:doc.status == 'Open' && doc.priority == 'High'"

Example: Display the field if status is Open and priority is High.

5. Multiple Conditions with OR

Show a field if any one of multiple conditions is true.

"depends_on": "eval:doc.status == 'Closed' || doc.status == 'Cancelled'"

Example: Display the field if status is either Closed or Cancelled.

6. Child Table Row Conditions

Show a field inside a child table row based on the row's data.

"depends_on": "eval:row.is_active"

Example: Display the field in a child table if the is_active field in the same row is checked.

7. Checkbox is Checked

Show a field if a checkbox is checked.

"depends_on": "eval:doc.is_active == 1"

Example: Display the field if the is_active checkbox is checked.

8. Checkbox is Unchecked

Show a field if a checkbox is unchecked.

"depends_on": "eval:doc.is_active == 0"

Example: Display the field if the is_active checkbox is unchecked.

9. Logged-in User

Show a field if the currently logged-in user matches a value.

"depends_on": "eval:frappe.session.user == 'Administrator'"

Example: Display the field only for the Administrator user.

10. Role-based Condition

Show a field if the logged-in user has a specific role.

"depends_on": "eval:frappe.user.has_role('Manager')"

Example: Display the field if the user has the Manager role.

11. Custom Python Script (Server-Side Evaluation)

Execute custom Python logic on the server.

"depends_on": "method:custom_method_name"

Example: Use a server-side method called custom_method_name to evaluate the condition.

12. Field Comparison

Show a field based on a comparison between two fields.

"depends_on": "eval:doc.start_date < doc.end_date"

Example: Display the field if start_date is earlier than end_date.

Notes on depends_on:

  • Eval vs Method:
    • Use eval:expression for client-side evaluations.
    • Use method:server_method for server-side evaluations.
  • Boolean Values:
    • Frappe evaluates JavaScript expressions in depends_on, so true or false values can control visibility.
  • Child Tables:
    • Use row for conditions within a child table row (e.g., row.fieldname).

Let me know if you'd like tailored examples or further explanation!

Common Conditional Statements for "Read Only Depends On"

1. Field Value Equals

Make the field read-only if another field has a specific value.

eval:doc.status == 'Closed'

Example: The field becomes read-only when the status field is set to Closed.

2. Field Value Does Not Equal

Make the field read-only if another field does not have a specific value.

eval:doc.priority != 'High'

Example: The field becomes read-only unless the priority field is set to High.

3. Field Value is Not Empty

Make the field read-only if another field is filled.

eval:!!doc.customer

Example: The field becomes read-only when the customer field is filled.

4. Same Field is Not Empty

Make a field read-only when the same field is not empty (i.e., it has a value).

eval:!!doc.fieldname

Explanation:

doc.fieldname: Refers to the value of the field itself.

!!: Converts the field value into a boolean:

true if the field is filled (non-empty).

false if the field is empty or null.

Example: If your field is named tracking_number, the condition would be:

eval:!!doc.tracking_number

This makes the tracking_number field read-only as soon as it is filled with a value.

5. Field Value is Empty

Make the field read-only if another field is empty.

eval:!doc.project

Example: The field becomes read-only when the project field is empty.

6. Checkbox is Checked

Make the field read-only if a checkbox is checked.

eval:doc.is_active == 1

Example: The field becomes read-only when the is_active checkbox is checked.

7. Checkbox is Unchecked

Make the field read-only if a checkbox is unchecked.

eval:doc.is_active == 0

Example: The field becomes read-only when the is_active checkbox is not checked.

8. Multiple Conditions with AND

Make the field read-only if multiple conditions are true.

eval:doc.status == 'Closed' && doc.priority == 'High'

Example: The field becomes read-only when status is Closed and priority is High.

9. Multiple Conditions with OR

Make the field read-only if at least one of multiple conditions is true.

eval:doc.status == 'Cancelled' || doc.status == 'Closed'

Example: The field becomes read-only when status is either Cancelled or Closed.

10. Field Comparison

Make the field read-only based on a comparison between two fields.

eval:doc.start_date >= doc.end_date

Example: The field becomes read-only if start_date is greater than or equal to end_date.

11. Logged-in User

Make the field read-only for a specific user.

eval:frappe.session.user == 'Administrator'

Example: The field becomes read-only only for the Administrator user.

12. Role-Based Condition

Make the field read-only for users with a specific role.

eval:frappe.user.has_role('Manager')

Example: The field becomes read-only for users with the Manager role.

13. Child Table Row Conditions

Make a field inside a child table read-only based on row data.

eval:row.is_active == 1

Example: A child table row field becomes read-only if the is_active field in the same row is checked.

14. Custom Date-Based Condition

Make the field read-only if the current date meets a condition.

eval:frappe.datetime.get_today() > doc.expiry_date

Example: The field becomes read-only if the current date is past the expiry_date.

15. Time-Based Condition

Make the field read-only based on a specific time range.

eval:frappe.datetime.now_time() >= '18:00:00'

Example: The field becomes read-only after 6:00 PM.

16. Dependent on Custom Script

Make the field read-only using a custom script method.

method:custom_read_only_check

Example: This uses a server-side method called custom_read_only_check to determine if the field should be read-only.

Key Notes

  • Boolean Logic: Use && (AND), || (OR), and ! (NOT) for complex conditions.
  • Eval vs Method:
    • eval is evaluated on the client side.
    • method calls a server-side Python function.
  • Dynamic Checks: Use session variables, date/time functions, or child table values for dynamic conditions.
  • Field References: Use doc.fieldname to reference fields in the same document, and row.fieldname for child table rows.

Let me know if you’d like specific examples for your use case!

Was this article helpful?