cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Veronica
Resolver I
Resolver I

Choose 3 field from a support table dropdown into my main table

Hi, everyone:

 

I have my main table called Detail where the created records are saved. I have also a support table that has Judge name, judgeId, JudgeDescr.  In the form of edit / add  I want the user to choose the name of a judge but I want to save not only the name but the judge's id and JudgeDescr in the main table.

 

I read a lot of blog but almost everything is to show one field and to save another but I want to show the name (Judge Name) in a dropdown but save 3 fields from that support table (Judge) to my main table Detail.

 

Any help I will appreciate it!

 

Veronica

 

 

 

 

8 REPLIES 8
Drrickryp
Super User II
Super User II

Hi @Veronica,

While a Dropdown control only shows one value in its window, it actually contains an entire record and all of the columns in that record can be referenced. You can see what columns are available by selecting the dropdown control and checking the right hand column under Advanced->Value.

dropdown.PNG

 

If you have a Patch() statement for saving your data, the syntax would be something like

Patch(Main,Defaults(Main),{JudgeName: Dropdown1.Selected.JudgeName, 
JudgeID: Dropdown1.Selected.JudgeID,
JudgeDescr: Dropdown1.Selected.JudgeDescr})

The above syntax would add a new row to the Main table from a dropdown control having a table of Judges as its Items property.  

Veronica
Resolver I
Resolver I

Hi Everyone:

 

I hade to create 3 datacard, two values ( judgeID and Judge descrip) change depending on the judgename.  Labels on this 2 Datacard showing variables varTS and VarNombra.  On the dropdown properties On Select and ON Change I had to code:

 

Set(varJuez,ddJuezMuni.Selected.Value);
Set(varTS,ddJuezMuni.Selected.supremecourt_id);
Set(varNombra,ddJuezMuni.Selected.vNombramiento)

 

Then I assign the variable to the 

Hi Everyone:

 

I hade to create 3 datacard, two values ( Supremecourt_id and vNombramiento) change depending on the judgename value. Text properties on the Labels of this 2 Datacard showing variables varTS and VarNombra. On the dropdown properties On Select and ON Change of the dropdown from where the user will choose the name I had to code:

 

Set(varJuez,ddJuezMuni.Selected.Value);

Set(varTS,ddJuezMuni.Selected.supremecourt_id);

Set(varNombra,ddJuezMuni.Selected.vNombramiento)

 

Then I assign the variable to the fields on my Detail table.  

 

It work but I will try also with Patch.

Hi  Drrickryp:

 

Thank you for the recommendation.  I will try with Patch and let you know.

 

Regards,

 

veronica

v-xida-msft
Community Support
Community Support

Hi @Veronica,

Do you want to save three field values from your Support Table into your Main Table?

Which type columns do you use to store the Judge name, judgeId, JudgeDescr value?

Based on the needs that you mentioned, I agree with @Drrickryp's thought almost, I think the Patch function could achieve your needs.

I assume that you created three separated Single line of text type columns to store the Judge name, judgeId, JudgeDescr value from the Support table in your Main Table.

I have made a test on my side, please take a try with the following formula:

Set the Items property of the JudgeDropdown control within your app to following:

'YourSupportTable'

Within the right Advanced tab panel, set the Value property to Judge Name column which you want to display within the JudgeDropdown control.

Set the OnSelect property of the "Submit" button to following:

 

Patch(
        'YourMainTable',
        Defaults('YourMainTable'),
       {
          JudgeName: JudgeDropdown.Selected.Judgename,
JudgeId: JudgeDropdown.Selected.judgeId,
JudgeDescr: JudgeDropdown.Selected.JudgeDescr } )

Note: The JudgeName, JudgeId and JudgeDescr are all columns in your Main Table. The Judgename, judgeId and JudgeDescr are all columns in your Support table.

More details about Patch function in PowerApps, please check the following article:

Patch function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Kris:

 

First I want to thank you and Drrickryp for take time to answer my questions.  I am the only one learning PowerApps and programming at the same time with some date to comply!!!.  I only have these community to consult my doubts. In this journey I am alone.

 

Answers:

 

Do you want to save three field values from your Support Table into your Main Table? - YES.

Which type columns do you use to store the Judge name (VARCHAR), judgeId(INTEGER), JudgeDescr(VARCHAR) value?

I will try wth Patch And let you know.

 

Thanks again,

 

Veronica

 I incorporate the changes with the Patch code but it didn't save the info in my main table Detail.  I am sure the problem is that I  tested the code on the On Select property of the dropdown and not on the Summit button.  I have to clean all the other code completly.  I will tested again and let you know.

 

Thanks,

 

Veronica

Well,

The status of my work is that I spend all day try to make Patch work and I couldn't. Firts I can't use Defaults because it dulicate records with the Submit form function.  This is my code at the Submit button:

 

SubmitForm(FormLey148);
If(Muni = 1,
Patch('[dbo].[Ley148_2015]',
Filter('[dbo].[Ley148_2015]', StartsWith(vOfficeLocation,Oficina) && vNumeroOrden=lblNumeroOrden.Text)),
{
vJuezInicial:ddJuezMuni2.Selected.vJuezDescripcion,
vSupremeCourtInicial: ddJuezMuni2.Selected.supremecourt_id,
vNombramientoInicial: ddJuezMuni2.Selected.vNombramiento
}
);
If(Super = 1,
Patch('[dbo].[Ley148_2015]',
Filter('[dbo].[Ley148_2015]', StartsWith(vOfficeLocation,Oficina) && vNumeroOrden=lblNumeroOrden.Text)),
{
vJuezInicial:ddJuezSuper2.Selected.vJuezDescripcion,
vSupremeCourtInicial: ddJuezSuper2.Selected.supremecourt_id,
vNombramientoInicial: ddJuezSuper2.Selected.vNombramiento
}
);
Navigate(BrowseLey148Screen,ScreenTransition.Cover)

 

\**

I have to discriminate between two types if judges Muni or Super thats why the Patch is inside the if condition.  I change the code if ..else.  If and another If.  I think my filter is the problem but I recycle the dilter from a gallery that works.

 

Any help I will appreciate.

 

Veronica

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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