Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add eval support for link field filters #25453

Merged

Conversation

RitvikSardana
Copy link
Contributor

@RitvikSardana RitvikSardana commented Mar 14, 2024

Users can add dynamic filters based on some value from the form.

Use:

eval: doc.fieldname

or

eval: doc.fieldname1 + doc.fieldname2

Screen.Recording.2024-03-14.at.11.16.54.PM.mov

For Child Tables
2 types of filters can be added.

  • From the Child Table Row: to add these filters use doc.child_table_field_name

  • From Parent Document: to add these use parent.parent_doc_fieldname

Screen.Recording.2024-03-19.at.12.21.08.PM.mov

the expression added after "eval:" is evaluated and its value is returned.

docs: https://docs.erpnext.com/docs/user/manual/en/creating-custom-link-field#adding-filters-to-link-field

@RitvikSardana RitvikSardana requested a review from a team as a code owner March 14, 2024 17:49
@RitvikSardana RitvikSardana requested review from akhilnarang and ankush and removed request for a team March 14, 2024 17:49
frappe/public/js/frappe/form/form.js Outdated Show resolved Hide resolved
frappe/public/js/frappe/form/form.js Outdated Show resolved Hide resolved
@ankush ankush marked this pull request as draft March 15, 2024 09:31
@ankush
Copy link
Member

ankush commented Mar 15, 2024

Mark as ready when done

@RitvikSardana RitvikSardana marked this pull request as ready for review March 19, 2024 06:53
@barredterra
Copy link
Collaborator

If they are part of the doctype definition already, can we also validate these filters in the backend? A common cause of unexpected behavior is when filters are set but users can still circumvent them, for example by pasting a different value or using the browser console.

@ankush
Copy link
Member

ankush commented Mar 27, 2024

@barredterra eval stuff will be JS so again it will hard to redo it in server side.

Also, we are starting a client rewrite project soon-ish, we'll figure out a better way to represent some of these things so they can be validated on both client and server side. (Not just search field but other validations too)

@ankush
Copy link
Member

ankush commented Mar 27, 2024

@GursheenK @ruchamahabal FYI ^

@ankush ankush merged commit f11313d into frappe:develop Mar 27, 2024
24 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants