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

Enable Dynamic Links to obtain its options from a specific DocType, rather than all DocTypes. #22512

Open
bosue opened this issue Sep 22, 2023 · 0 comments

Comments

@bosue
Copy link
Contributor

bosue commented Sep 22, 2023

When implementing a Dynamic Link field, the options source may either be a Select or a regular Link field.

Now if the source is another Link field, there is the additional requirement that this other Link field must have “DocType” as its options source.

This rule is enforced by Frappe throwing an exception so the DocType can’t be saved. The relevant code may be found here.

This second rule is overly strict and should at least be expanded a bit to also allow meta DocTypes such as Party Type. Fact is that it does work really nicely without any problems if specified directly in the JSON file.

For an example, please see what is being done in frappe/erpnext#37195.

You just can’t save the DocType in the UI editor anymore, for this exception being thrown:

RPReplay_Final1695389909.mov

But if implemented in JSON, it works quite well, just as expected.

Basically Party Type works as a pre-selection filter that allows handpicking a couple of the many, many DocTypes so you don’t have to specify them statically in a select or provide them by custom JS code:

RPReplay_Final1695391020.mov

There are already a few usecases particularly for Party Type, including in frappe/lending. I can imagine this to be a quite powerful thing to do in other cases as well.

So I think we should slightly loosen the enforced rule to (officially) allow this to be done. But of course we need to be careful and find out what exactly is needed to ensure a Dynamic Link field doesn’t break. And then we need to figure out how to put this into words, so power users understand it better, not worse than today.

@bosue bosue changed the title Allow Dynamic Links to obtain its options from a specific DocType, not necessarily from the full list of DocTypes Enable Dynamic Links to obtain its options from a specific DocType, rather than all DocTypes. Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant