How to make a field of Link type with the possibility of adding a user-defined value

I want to have a field in a custom Doctype that performs the following task:

List all registered customers in the system and offer the possibility of using a user-defined customer (you only need to enter a customer’s name).

How can I achieve this?

My first idea was to replicate the same behavior of another field which is of Select type and shows a list of predefined items. The last item in the list is Other, which offers the possibility of adding a user-defined value.

When that item is selected, the current field of Select type is replaced by a field of Text type where the user can write a new value.

You need three fields that should do the job for you.

  1. Data Field - Labeled ‘Customer Name’
  2. Link Field - Labeled ‘Customer’
  3. Check Field - Labeled ‘Existing Customer’

When Existing Customer is set to Yes - Linked field Customer is available to select the Customer and this Customer Name field is hidden but the value will be fetched from the Customer itself using Fetch From or Options facility.

its default value will be zero, hence the Customer Name field will be available. You can write the name as you want.

1 Like

Thanks! I think it’s a very good solution :+1:

1 Like