cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc
Resolver II
Resolver II

Default a dropdown value by the value of another field in the same list

I have 2 SP Lists...

List of Aircraft (containing an ID, DisplayName,....)

List of ChargeBacks(containing an ID, AircraftID, Amount, etc...)

In a relationship db setting the Aircraft List has a one to many relationship with the Charges List 

where aircraft.id=ChargeBacks.aircraftId

 

On my Chargeback form I want the ability to select the aircraft from a dropdown list of aircraft where I display the aircraft.displayname. Done.

The value of the ChargeBacks.aircraftId appears on the form nicely.

 

But my issue is that I want the default value of the dropdown list to reflect the value of the displayname for the ChargeBacks.aircraftId value.

 

Note: Both ID and aircraftId are numeric values and they are not a lookup column in the list currently (as I wanted to try and make this work with Power Apps minus any "lookup column" concerns.

 

The default value of the Aircraft dropdown field is....

If(SharePointForm1.Mode=FormMode.New,"(-)",LookUp(Aircraft,ID=ChargeBacks.AircraftId.Value,DisplayName))

To which I get this error...

I'm trying to say if the Form Mode is new then display the one with (-) in the dropdown list (essentially I want it to be blank), but if not display the DisplayName based on the value of the ID (in Aircraft) matching the AirCraftId value (in Chargebacks).

 

I have playing/editing to no avail...

 

Likewise the AircraftId value when in edit mode/new mode will reflect the ID value for the dropdown ID value of the displayName.

 

It is worth noting that the Aircraft dropdown is situated out of the "form" area 

 
 

 

 

sasrsc_0-1598309172010.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks Warren for your assistance. In the end, after some research, I took a different tact. I'm not saying your method isn't an option but I found this worked better for my brain and the specific need. I decided to create a variable. My whole solution was ripe for a variable and I just hadn't explored that much.

 

1. Dropdown field containing Plane Names (defaults to the Display Name of #2 if an existing row : AircraftDropDown)

2. Input field contining Plane ID (contained the current plane ID value from the SP List: Chargebacks.AircraftId named IpExistingAircraft)

3. Variable to store the Plane Name ID Selection (set when the user changes the dropdown value called ddAircraftId)

 

 

Some settings:

1. Default=LookUp(Aircraft_1,ID=Value(ipExistingAircraft.Text),DisplayName)

OnChange=Set(ddAircraftId,LookUp(Aircraft_1,DisplayName=AircraftDropDown.Selected.DisplayName,ID))

Items=SortByColumns(Aircraft_1.DisplayName,"DisplayName")

 

 

2. Default=If(IsBlank(ThisItem.AircraftId),ddAircraftId,ThisItem.AircraftId)

 

Form onSave. SubmitForm(SharePointForm1);Patch(ChargeBacks,SharePointIntegration.Selected,{AircraftId:Value(ddAircraftId)})

 

I did this but I thinking I could set the variable value to the ThisItem.AircraftId before I submit therefore not needing the patch. However, this appears to work with my testing. It may be overkill but technically it's my first successful attempt at a more "true" relationship database in PA using SP Lists.

Sharing in case it helps others.

 

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @sasrsc ,

You noted AircraftId was a Numeric field in Chargebacks? A Lookup will also only get one value (the first matching)

If(
   SharePointForm1.Mode=FormMode.New,
   "(-)",
   Filter(
      ChargeBacks,
      AircraftId=SharePointIntegration.Selected.ID
   ).DisplayName
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Hi @sasrsc ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks Warren for your assistance. In the end, after some research, I took a different tact. I'm not saying your method isn't an option but I found this worked better for my brain and the specific need. I decided to create a variable. My whole solution was ripe for a variable and I just hadn't explored that much.

 

1. Dropdown field containing Plane Names (defaults to the Display Name of #2 if an existing row : AircraftDropDown)

2. Input field contining Plane ID (contained the current plane ID value from the SP List: Chargebacks.AircraftId named IpExistingAircraft)

3. Variable to store the Plane Name ID Selection (set when the user changes the dropdown value called ddAircraftId)

 

 

Some settings:

1. Default=LookUp(Aircraft_1,ID=Value(ipExistingAircraft.Text),DisplayName)

OnChange=Set(ddAircraftId,LookUp(Aircraft_1,DisplayName=AircraftDropDown.Selected.DisplayName,ID))

Items=SortByColumns(Aircraft_1.DisplayName,"DisplayName")

 

 

2. Default=If(IsBlank(ThisItem.AircraftId),ddAircraftId,ThisItem.AircraftId)

 

Form onSave. SubmitForm(SharePointForm1);Patch(ChargeBacks,SharePointIntegration.Selected,{AircraftId:Value(ddAircraftId)})

 

I did this but I thinking I could set the variable value to the ThisItem.AircraftId before I submit therefore not needing the patch. However, this appears to work with my testing. It may be overkill but technically it's my first successful attempt at a more "true" relationship database in PA using SP Lists.

Sharing in case it helps others.

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,875)