Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Confusion on Linking forms
- This topic has 9 replies, 3 voices, and was last updated 4 years, 2 months ago by Sam Moffatt.
-
AuthorPosts
-
August 25, 2020 at 10:55 PM #41745
Mark RudolphiParticipantI have two forms – Vendor and Products.
Vendor’s form has their name, phone, address, etc.
The product form has many products each with various info about the product including vendor. For each product in the form, I want user to pick from a list of vendor names from the vendor forms.
I’m currently doing this with a pick list that uses field vendor from the form Vendor.
It works fine but in IOS the user can type in a vendor name that isnt in the list. I dont want that. I want to force the value to only be a vendor from the vendors form. Is there a way to prevent a user from typing in their own vendor name?
August 26, 2020 at 2:22 AM #41749
BrendanKeymasterHi Mark,
What you probably want is to add a Link to Form field from your Vendor form to your Products form. Most likely a One to Many relationship from Vendor to Products. I’m sure you wouldn’t have the same product coming from multiple vendors. Or maybe you might. I’m not sure. That’s up to you.
When you setup this relationship, you’ll only be able to select from the available vendors on your Products form. Or if editing products from the Vendor perspective, you would select products that are provided by the currently selected vendor.
There’s more information on relationships here:
https://www.tapforms.com/help-mac/5.3/en/topic/relationships
Thanks!
Brendan
August 26, 2020 at 6:13 AM #41750
Mark RudolphiParticipantThank Brendan
You are correct that I wouldnt have the same product from multiple vendors. I had tried this (and just tried again) but I’m still able to create a vendor name from the product form. I read the link but I must be doing something wrong here, I just dont know what.
What I want is while adding a product in the product form, in the vendor field while in the product form, have a selection of vendors to choose from. I dont want the user to be able to add a new vendor from the product form. You should only be able to add a new vendor when in the vendor form. User should not be able to save a vendor name in the product form that isnt in the vendor form. No matter how I set it up, I can still put anything I want in the vendor field of the product form.
August 26, 2020 at 8:47 AM #41752
Sam MoffattParticipantIn your Vendors form create a new “Link to Form” field, link it to your Products form, make sure it’s set to one to many (1:M) and tick “show inverse relationship”. Then in your Products form you will have a new “Vendor” field that will be link to the Vendor form. It’ll still have the ability to add new entries but when someone adds from that interface it’ll use the Vendor form.
August 26, 2020 at 10:56 AM #41760
Mark RudolphiParticipantSam
Thank you. I think I got it working now.August 26, 2020 at 12:52 PM #41763
Mark RudolphiParticipantWhats the exact equivalent to what I have but instead of allowing only one selection you can allow many? I assume its many to many link type.
However, with a set up like this there are two thing I dont like.
1) in the form, your selections that were made don’t show, instead you see just a counter of the number of selections made. Prefer to see the selection(s) made in the form itself instead of just the number of selections. Anything I can do here?
2)When you select field to make your selection, the list isnt offered up first. Instead you see a prompt that says tap the + button to create a record. Prefer to see the linked list pop up first to choose from first. Otherwise user may think they need to create the “record” when its already available.I assume in this case I’m better off using a pick list instead of a linked field type.
On a separate note, I realized one more issue with a linked field type – once you create a link, you can’t sort the form by a linked field. Is that correct or am I missing something?
Grr one problem solved two created.August 26, 2020 at 7:21 PM #41768
Sam MoffattParticipantFor the many to many link type, there was a quirk where the “show inverse relationship” needed to be toggled to reset the field on the other side of the link but that will let you map many to many on both sides.
1. If you’re on the child side of a 1:M relationship, it should be showing you a cut down view of the linked record. If you’re on the parent side or using a M:M relationship, you need to use a script field to aggregate the values and display them. On the desktop it would display a table for you but on mobile a script field is probably your best bet.
2. The experience on iOS here is a little awkward because of where the various buttons end up and the hint text pushes towards adding a new value rather than selecting an existing value. I don’t think there is a good way around this one.
3. Linked fields mess with sort and search because the linked field itself has multiple fields and if it’s a multiple relation you have multiple records as well. The solution is again to use and have that flatten the records for you. Then the search and sorting can be done on the script field once you’ve extracted the value that works for you. If you are in a 1:M relationship, the child record can use a calculation field to extract a field from the parent easily.
4. For the pick list what you could do is have a script field enforce that the value exists and resets the vendor field if an invalid item is entered and then pops up an alert to the user. That’s a reasonable amount of scripting but also doable as an extra validation step.
August 30, 2020 at 8:02 AM #41791
Mark RudolphiParticipantSam
You mentioned
“1. If you’re on the child side of a 1:M relationship, it should be showing you a cut down view of the linked record. If you’re on the parent side or using a M:M relationship, you need to use a script field to aggregate the values and display them.On the desktop it would display a table for you but on mobile a script field is probably your best bet.”
Can you give me an example of what this script might look like or point me in the direction of where to learn? Thanks so much
Mark
August 30, 2020 at 12:16 PM #41794
Sam MoffattParticipantIf you jump into the script editor and look through the snippet list, you’ll find the “Child Records Loop” snippet. If you select the linked field you’re looking to render into the other form, it’ll put in a bunch of place holder text (delete the basic boilerplate Tap Forms gives you). I just did this on a post, it looks like this:
function recordsLoop() { var topics_id = 'fld-fae59d1ee3184c4cbec2eac87aeaa9ae'; var topic_title_id = 'fld-fce83c065b174df1919ada0de6e0551e'; var topics = record.getFieldValue(topics_id); for (var index = 0, count = topics.length; index < count; index++){ var topic_title = topics[index].getFieldValue(topic_title_id); if (topic_title) { // do something } } return; } recordsLoop();
If you wanted to make a comma separated list of all of the values, the
// do something
needs to gather together the values. To do this addvar returnValue = [];
after the other line that hasvar topics
on it, it’ll create an array we’ll use to collect values. Then change// do something
to bereturnValue.push(topic_title);
which will add the values to the array. Then finally change the line that hasreturn;
on it to bereturn returnValue.join(', ');
to give you a comma separated value. The final form should look like this:function recordsLoop() { var topics_id = 'fld-fae59d1ee3184c4cbec2eac87aeaa9ae'; var topic_title_id = 'fld-fce83c065b174df1919ada0de6e0551e'; var topics = record.getFieldValue(topics_id); var returnValue = []; for (var index = 0, count = topics.length; index < count; index++){ var topic_title = topics[index].getFieldValue(topic_title_id); if (topic_title) { returnValue.push(topic_title); } } return returnValue.join(', '); } recordsLoop();
You can pull in multiple fields as well by following the same convention. If you click on the field you are interested in and then click on “ID”, it’ll generate the
var field_name = 'field-id';
code for you. You can also double click on a field on the other side of the link and it’ll generate something like thetopics[index].getFieldValue
line with the field ID embedded into the generated code.If newlines are more your thing, change
returnValue.join(', ')
toreturnValue.join('\n')
. If you want to go a little more advanced in your formatting, using the script to update the new Markdown field will give you more programmatic control over formatting. -
AuthorPosts
You must be logged in to reply to this topic.