Populate a choice list with values based on a selected value from lookup
Hello friends,
I am trying to build a Sales module in Ninox.
My Setup (Database is attached):
1. Clients table with a subtable called 'Client Contacts'
2. Invoice table with a subtable called 'Invoice Items'
3. Products table with a subtable called 'Product Details'
Every client/customer can have multiple contacts that we can get in touch with.
When making a sale to a client/customer (creating an invoice for them) we have to select a Client from a lookup field (that displays only the names of customer businesses) on the Invoice form. Based on this selected lookup there is another choice field (Contact Name) on the Invoice form that should get auto filled with corresponding values (based on the Client name selected from the Clients table).
a) Is there a command/script that I can use in the Trigger on Update (of the Clients lookup) to autofill the Client Contacts in the Single Choice List (combo box).
b) Now based on the Client Contact that we select from the combo box, values in the 'Contact Phone', 'Contact Mobile' and 'Contact Email' get filled automatically (all these three fields are formula fields). What formula/script can we use.
I am new to Ninox and still learning..
Thanks,
Vermaji
---------------------------------------
4 replies
-
In Ninox you would use a dynamic choice field to create what is known as 'lookup' in other DBs. So you can delete the current choice field called Contact Name and create a new dynamic choice field with the same name.
Then under Dynamic Values you can put:
'Client Name'.'Business Contacts'
Then under Dynamic value name you can choose any field you want from the Business Contacts table.
-
On to part b, for 'Contact Phone' you can use the following:
let contactRec := record('Client Contacts',number(dC)); contactRec.Phone
dC is a new dynamic choice field from the previous post. Since we are using a dynamic field, Ninox stores the record Id, so we need to use the record() command so we can get access to the full record.
In the other field, you can replace Phone with whatever field you want to present.
If you made Contact Phone, Contact Mobile, Contact Email in Invoices into a static fields then you can put this into the Trigger after update of the dynamic choice field:
let contactRec := record('Client Contacts',number(dC)); 'Contact Phone' := contactRec.Phone; 'Contact Mobile' := contactRec.mobile; 'Contact Email' := contactRec.email
-
Hello your solution worked like charm. Thank you for the help..
Content aside
- Status Answered
- 5 mths agoLast active
- 4Replies
- 56Views
-
2
Following