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

Allow using a Table MultiSelect to narrow down a list of options available in another Link or Select field. #22550

Open
bosue opened this issue Sep 26, 2023 · 1 comment

Comments

@bosue
Copy link
Contributor

bosue commented Sep 26, 2023

This feature request is a bit complicated to read and follow, but fascinating:

There is the interesting use case of using a Table MultiSelect in DocType 1 (here: Loan Type) as source / list of allowed values in a Select or Link field in DocType 2 (here: Loan).

This aims at narrowing down the list of Modes of Payment available for a specific Loan Type, allowing Loans of that Loan Type to select only from this reduced list.

The same applies to Party Types, Territories, etc., making this a pattern that could be applied in various scenarios. I’m absolutely positive the pattern would soon be used in ERPNext and custom projects as well.

The desired structure fascinatingly kind of works, see the Table MultiSelect source field in Loan Type:
IMG_1660

… and the dependent Select field in Loan:
IMG_1659

One of the two reasons (for the other one, see the last few paragraphs) it only almost works is as follows:

The dependent Select field gets actually readable values only because in the child table “Loan Type Modes of Payment”, I’m configuring the field value as naming rule:
IMG_1661

This however necessarily turns the field unique. This in turn will in most cases be a bad idea because the same values can’t be selected for another Loan Type:

IMG_1658

(If you want exclusivity, that‘s the way to go. But here we don‘t want only a single Loan Type to allow for Wire Transfer.)

So instead, we may reset the child table’s naming rule to Random (or Autoincrement). This immediately fixes our problem: exclusivity is gone. It however creates a new problem: now the values offered in Loan‘s select field are identified by a random string:
IMG_1662

Again, there could almost be a solution: the title field and “Show Title in Link fields“:
IMG_1663

Almost, but not quite—child table doctypes lack these settings, as the entire ‘Settings’ tab is absent.

Now, while in the UI it is not possible to configure these, in the JSON file I can still set:

 "show_title_field_in_link": 1,
 "title_field": "mode_of_payment"

There we go:
IMG_1664

It’s still a bit rough, as we’re linking to the child table item instead of directly to the original Mode of Payment item:
IMG_1665

But again, we’re close.

If we only could use a Select rather than a Link field, so only the actual string values are taken into account, we’d be 100% there. But again, that’s not possible, because Select fields only allow for a static list of values listed one by one in the doctype.

Now I’m wondering how we may remove one or two of the remaining road blocks to make the interesting use case feasible without any custom JS code!?

@bosue
Copy link
Contributor Author

bosue commented Sep 27, 2023

My first idea how to solve it, would be a property pass_through or “Pass through from Link source” in the child table to do exactly this.

Then again, I’m unsure if there may ever be a useful case of not passing through the original values. If not, it may be preferable to just always do it.

Another option might be allowing a Table MultiSelect to be source for a Dynamic Link field’s options.

I will investigate both routes but would love to see comments by others indicating to me someone else is interested in a solution.

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