Hello All, I should start by saying, if ther...

Hello All,

I should start by saying, if thereโ€™s a better command to use (rather than LINKTOFORM), please let me know. Been using AppSheet for a few months nowโ€ฆstill learning.

The relevant tables Iโ€™m using areโ€ฆ

โ€œProspectsโ€ (Key = โ€œProspect IDโ€),

โ€œHousesโ€ (Key = โ€œHouse IDโ€),

โ€œAppointmentsโ€ (Key = โ€œAppointment IDโ€).

Multiple prospects can reside at one house and multiple appointments can be booked for one household.

When someone enters the app to book a new appointment, I have it setup to where they need to update any/all household and/or prospect details (and add an additional prospect, or resident, if weโ€™ve obtained new information about the prospectโ€™s spouse while booking a new appointment)โ€ฆ Once Prospectโ€™s info is up to date, the user can proceed with booking a new appointment.

To do so 1) The user selects a house

  1. They review and/or update household/prospect details .

  2. Once updated, they click on an action named โ€œNew Bookingโ€ to book a new appointment.

  3. Once they click on โ€œNew Bookingโ€ is where Iโ€™m having an issueโ€ฆ

Objective: User is linked to a form that has a filtered dropdown for that asks who they spoke to (โ€œBooked Appointment With?โ€ is what the form asks). Iโ€™d like for this dropdown to only list those 1 or 2 prospects that reside at the residence that they looked up prior to clicking on the action that brings them to the form.

Iโ€™m trying to use the LINKTOFORM option with a SELECT() command within the expression. Have tried lots of different expressions (using different combinations of [_THISROW], [House ID], and [Prospect ID]) but it continues to list all prospects when clicking on the dropdown.

Hereโ€™s a visual of one of the expressions Iโ€™ve tried (though I havenโ€™t achieved the desired result with it)โ€ฆ

LINKTOFORM("(Primary-Tabbed) NewAppt", โ€œRegionโ€, USERSETTINGS(Select Region),

โ€œCaller Nameโ€, USEREMAIL(), โ€œBooked Appointment Withโ€,

SELECT(Prospects[House ID],

[Prospect ID] = [_THISROW].[HouseID]))

Thanks in advance.

0 27 1,100
27 REPLIES 27

I should also add that the โ€œBooked Appointment With?โ€ is a REF type (to the โ€œProspectsโ€ table)

The SELECT expression will give you always a list, not a valueโ€ฆ even if there is only one value in that list. Before going too deep, try ANY(SELECT(โ€ฆ)

A step forward!

Iโ€™ve tried this and, although the dropdown still lists all prospects in DB, the form was pre-filled with the prospects nameโ€ฆBUT, this is only when one person lives at that household.

If there are 2 residents that we have for that household, it pre-fills the form with an EnumList type of value, which only lists the prospect IDโ€ฆrather then their full nameโ€ฆheres a screenshot of thisโ€ฆ

Instead of this, Iโ€™d like to achieve a filtered dropdown which shows these two Prospectsโ€™ full names, then the user can select which person they spoke with.

Also, to answer your โ€˜Main questionโ€™ from aboveโ€ฆ

To start, the majority of households in DB will only have one resident. But, as time goes on, we highly encourage users to add data on each household as we interact with them. So, as time goes onโ€ฆmore and more households will begin to have the husband and the wife listed as residents of each house.

(Also, hereโ€™s a screenshot of the pre-filled value when only one resident lives there)

Your original expression, reformatted for my clarity:

LINKTOFORM(

โ€œ(Primary-Tabbed) NewApptโ€,

โ€œRegionโ€,

USERSETTINGS(โ€œSelect Regionโ€),

โ€œCaller Nameโ€,

USEREMAIL(),

โ€œBooked Appointment Withโ€,

SELECT(

Prospects[House ID],

([Prospect ID] = [_THISROW].[HouseID])

) )

Specifically:

SELECT(

Prospects[House ID],

([Prospect ID] = [_THISROW].[HouseID]) )

This confuses me. Yourโ€™e requesting the list of house IDs (Prospects[House ID]), but you seem to already have the house ID ([_THISROW].[HouseID]). And youโ€™re comparing a prospect ID to a house ID?

Iโ€™d expect that SELECT() to be (based on an intuitive understanding of the DB structure):

SELECT(

Prospects[Prospect ID],

([House ID] = [_THISROW].[HouseID]) )

Rather than trying to pass a computed list of prospects based on the house, Iโ€™d pass the house ID and let the form itself compute the list of possible prospects using a Valid_If formula for Booked Appointment With that uses the passed house ID to construct the list of prospects. But it appears the house ID isnโ€™t currently stored in the appointments tableโ€ฆ

The reason youโ€™re getting the behavior you are is because Booked Appointment With is (presumably) a non-list column type (presumably Ref to Prospects).

When your SELECT() results in only a single prospect, the Booked Appointment With column is getting exactly what it expects: a single prospect ID.

When the SELECT() produces multiple prospects, the Booked Appointment With column isnโ€™t expecting a comma-separated list, so it tries to interpret what itโ€™s given as a single prospect ID. But because it isnโ€™t a single prospect ID, it canโ€™t find a matching row in the Prospects table, so it canโ€™t get a label to display. With no label to display, it falls back to displaying the given (unrecognized) value.

Hi Steve, appreciate the input!

The original expression Iโ€™d posted was more for a visual reference as to what I was trying to achieve within the question I was asking.

Still a bit of an amateur with AppSheet and trying to understand the science behind the way the SELECT() function works when listed within another function while used to pre-fill a form.

Iโ€™m not sure why I do not have the house ID listed within appointments table, but now that you mention itโ€ฆits gonna be vital for future endeavors and operations I have in mind for our office. So thank you for bringing that up!

To make sure I understand once Ive added [House ID] to appointments tableโ€ฆ

  1. The column type for House ID will be a REF to the โ€œHousesโ€ table.

  2. Since Iโ€™d want the value of House ID to be hidden and automatically filled in with each appointment submission, the โ€œApp Formulaโ€ would be [House ID].[House ID]

  3. I should enter Valid_If expressions within the โ€œProspect Lookupโ€ column and the (newly created) โ€œHouse IDโ€ column (and not use any SELECT() function within the LINKTOFORM() expression that has been previously discussed) in โ€œAppointmentsโ€ tableโ€ฆ

Within the โ€œAppointmentsโ€ table, the expressions for these columns should beโ€ฆ

โ€œProspect Lookupโ€ column (or โ€œBooked appointment With?โ€ as listed in form)

Valid_If Prospects[Prospect ID]

โ€œHouse IDโ€ column Valid_If Prospects[House ID]

Does all this look correct?

Again, thanks to both commentatorsโ€ฆthis discussion has been very helpful so far!

@Jonathan_Havens, weโ€™re all learning.

SELECT() is a particularly complex function and easily one of the hardest to grasp. You arenโ€™t alone in finding it a challenge!

Glad youโ€™ve taken the suggestion to add house ID to the appointment table!

To address the numbered points of your reply:

  1. Correct, the House ID column should be of type Ref pointing to the Houses table.

  2. In fact, you do not want an App formula for House ID, as that will prevent it from receiving the value from elsewhere.

If you want to prevent the user from modifying the House ID value in the appointments table, you can set the columnโ€™s Editable_If property to =FALSE.

You could use the House ID columnโ€™s Show_If property to hide it from from the user in form view, but be careful if Apply show-if constraints universally is ON in UX > Options > FORMS. If ON, the Show_If property will affect the columnโ€™s visibility everywhere.

You could instead use a slice (Data > Slices) to hide the column in the form only.

It may not be a bad idea to keep the column visible, though, to remind the user, especially if itโ€™s a long form.

  1. Correct that you should not use a SELECT() statement with LINKTOFORM(). Correct that you should use an expression in the Valid_If property of the Prospect Lookup column. Correct that the expression should make use of the new House ID column to locate the appropriate prospects.

The specific Valid_If expression for the Prospect Lookup column can be as simple as:

=Prospects[Prospect ID]

which will produce a list of all prospects, but you said you only want to present the prospects attached to the house. So Valid_If is where you want to use your SELECT():

=SELECT(

Prospects[Prospect ID],

([House ID] = [_THISROW].[House ID]) )

Look familiar? After all this, you just had your SELECT() in the wrong place.

Yes, my head was swimming the other day trying to figure out what I was doing wrong within that expression! So, itโ€™s good to hear Iโ€™m not alone on this.

Iโ€™ve tried using your advice in a few different ways and am getting an empty dropdown for the โ€œProspect Lookupโ€ field in form.

Am I understanding correctlyโ€ฆ 1) add Prospects[Prospect ID] in the โ€œProspect Lookupโ€ column and 2) add your concluding SELECT() expression within the Valid_If of the โ€œHouse IDโ€ column?

Or are you saying just to use the SELECT() expression within the โ€œProspect Lookupโ€ column, instead of the first Prospects[Prospect ID] Valid_If expression youโ€™d mentioned?

Maybe neither are correct? haha

Strictly speaking, you donโ€™t need a Valid_If expression for House ID, since youโ€™ll be populating the form value from LINKTOFORM().

So weโ€™re really only concerned with Prospect Lookup.

For Prospect Lookup, we want to tell AppSheet to only allow prospect IDs.

To do that, weโ€™ve made the column type Ref pointing to the Prospects table.

And we want AppSheet to present the user with a dropdown menu of valid prospects that the user can choose from. We can do that using the expression, =Prospects[Prospect ID].

But this gives a list of all prospects, where we only want the prospects associated with this house.

This is where the SELECT() expression comes in. Wrapped around Prospects[Prospect ID], the SELECT() โ€œselectsโ€ only some of the values instead of all. Which values is determined by the subexpression, ([House ID] = [_THISROW].[House ID]).

Iโ€™ve tried this out. Itโ€™s filling the field with the House ID or the prospect ID (as Iโ€™m trying different expressions)โ€ฆrather then the prospects name. Even when it fills with the ID, If I click on the dropdown, its still showing every prospect name, not just the ones who reside at that address.

Iโ€™m not quite sure that Iโ€™m using the combo of [_THISROW], [House ID], and [Prospect ID] in the correct sequence within the expression though either (which is why I keep โ€œtrying different expressionsโ€).

Additionally, Iโ€™ve been trying to find a helpful tutorial and Iโ€™ve come across one were thereโ€™s one thatโ€™s pre-filling the form without using the [_THISROW] feature. Shown hereโ€ฆ youtube.com - AppSheet Office Hours | How to Make an Inventory Management App II (Relevant material starting at 24:10)

AppSheet Office Hours | How to Make an Inventory Management App II

Ok, Iโ€™ve copied and pasted the expression youโ€™d listed and tested it out.

Itโ€™s giving me a blank dropdown for the โ€œSpoke with?โ€ field.

I also ran a test on the expression and something jumped out at meโ€ฆthe value thatโ€™s filled in for [_THISROW] becomes โ€œAppointment IDโ€. This should be altered, yea?

Hereโ€™s the screenshot of the testโ€ฆ

Itโ€™s OK that it replaces [_THISROW] with [Appointment ID]. Because the Appointment ID column is the KEY column for the Appointments table, the two are equivalent.

That you get a blank dropdown suggests there are no prospects attached to the house you chose.

I ended up looking for other things that could have been causing the issueโ€ฆsince there were prospects attached to the houses Iโ€™d tested this on (I deleted all the address without the attached prospect info). Slices, partitions (I have 3), and security filtersโ€ฆcouldnโ€™t find anything that would be blocking the prospect info from showing up.

However, I had the idea to place the โ€œHouse IDโ€ above the โ€œProspect Lookupโ€ within the form, since itโ€™s always one unique valueโ€ฆthen list the related prospects, based on the household with a Valid_Ifโ€ฆIT WORKED!! Super excited to have gotten this fixed!!

Thank you so much for all your help throughout this process! You and Aleksi have been quick to respond and, at a certain point, my mind was swiss cheese with all the possibilities as to where Iโ€™d need to put the SELECT() function (is it the App formula, Valid_If, within LINKTOFORM() function, etc.).

โ€œWith great power comes greatโ€ฆpossibilitiesโ€

ha

Anyhow, itโ€™s working great. Nowโ€ฆif itโ€™s not too much of a headache, Iโ€™d like to add the โ€œNew Bookingโ€ as a prominent action within the โ€œProspect Detailsโ€ view. When clicked, have it pre-fill the โ€œHouse IDโ€ and the โ€œProspect Lookupโ€ values. Iโ€™m guessing itโ€™ll just be a small variation from the settings youโ€™ve been helping with.

Also, I wanted to ask you about the โ€œHide menu and search buttonsโ€ setting. It seems illogical to group these two functions together as one setting. Iโ€™d like to keep the search button throughout the app, but turn off the hamburger menu. Is this a possibility?

@Jonathan_Havens There is no way to turn off the main menu without also turning off search. I donโ€™t know why those are lumped together.

Steve,

I assume this is still the case? Main Menu and Search lumped together?

Thanks

Looks that way.

What values your column โ€œBooked Appointment Withโ€ is using? Can you take a printscreen from your Prospects table?

Sure. Here are the 3 tables Iโ€™m using. Iโ€™ve circled the column which Iโ€™m trying to fill. Itโ€™s actually named โ€œProspect Lookupโ€โ€ฆIโ€™ve been saying โ€œBooked Appointment Withโ€ as an easier way for the community to understand what Iโ€™m trying to achieve. In expression, Iโ€™m using โ€œProspect Lookupโ€.

Prospects Table (Ill post the other 2 in separate comments)

Appointments Table (which includes the value in question)

Houses Table

I really appreciate your help here. I was trying at this for a few hoursโ€ฆgot very frustrating. Usually Iโ€™m able to track down the solution. Being that this is an expression within an expressionโ€ฆI havenโ€™t been able to find much help on how this should work.

And the โ€œNew Bookingโ€ you are triggering from which table?

In this case, I have the action โ€œDisplayed prominentlyโ€ within the Houses_Details view.

I also wanted to create an action within the Prospects_Details view.

So, whether user is looking at household details or an individual prospects details, they can click on the โ€œNew Bookingโ€ action and the form will either:

A) From Houses_Details > filter the โ€œProspect lookupโ€ to only show the prospects that reside at that residence.

or

B) From Prospects_Details > pre-fill the โ€œProspect lookupโ€ with the prospectโ€™s name that they were viewing when clicking on โ€œNew Bookingโ€

But I feel like I can figure option B if I have option A figured out (which seems to be the more complicated one)

I try to summarizeโ€ฆ You want to read the related Prospect from the Houses record. The problem is the value itselfโ€ฆ because itโ€™s a list of Key columnโ€™s values. Main question isโ€ฆ does that list contains more than one value or is it always just one value?

The below formula would give you the same resultโ€ฆ I mean list of values but itโ€™s a start to find the suitable value from that list.

LINKTOFORM("(Primary-Tabbed) NewAppt", โ€œRegionโ€, USERSETTINGS(Select Region),

โ€œCaller Nameโ€, USEREMAIL(), โ€œProspect Lookupโ€,

[Related Prospects])

Top Labels in this Space