cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Chiper
Level: Powered On

Submitting Multiple Forms When Form B References The New Record Of Form A?

Heeeeelllllpppppp......

 

New to Power Apps and thought a tiny business challenge could be solved with a simple Power App. After all it's marketed as no code so how hard could it be 😉 

 

Two days of googling and YouTube videos, I have created my custom entities, input some test data (manually) and built a Power BI Dashboard. The inbuilt entities (Address and Account) scared me with all their fancy fields so I am using CDS with custom entities.

 

PFPCompany

  • Company Name
  • Business Phone
  • Website

 

PFPAddress

  • Company (lookup field PFPCompany-Company Name)
  • Address Line 1
  • Suburb
  • City
  • State
  • Post Code
  • Country 

 

Everything was going well all that was left was to create the front end app so users could start inputting the data and interact with it (edit, delete, etc).

 

I created a Blank Canvas App (Tablet) and created my first page (Add Company). I added two forms Company and Address. So far so good, time to test the input. Everything works fine until we get to the Company field on the Address form. Obviously we haven't submitted the Company form yet thus the new company record doesn't exist within the drop down list for the user to select. Nor should they need to as they are creating a new company.

 

In my mind I thought this was fairly simple to solve 

  1. Button.OnSelect = SubmitForm(Company)
  2. Get the value of the Unique Identifier for the new Company record that was just created
  3. Update AddressForm.CompanyName to theUnique Identifier for the new Company record that was just created
  4. SubmitForm(Address)

 

I am completely stumped.... I have googled for hours and come up with nothing. It doesn't seem like this is possible? If that is the case I am assuming we are suppose to store the address information within the PFPCompany entity but a company can have multiple locations so how do we then handle that situation? 

 

I also need to store the primary contact which I haven't tackled yet but I would face the same problem as this would be a third form Contact that would submit to the PFPContacts entity. 

 

Kudos if you have read this far. Bonus points if you can point me in the right direction as I'm ready to pack up my bat and ball and go back to one giant spreadsheet..... 

 

Cheers,

Chiper

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

Hi @Chiper ,

Do you want to submit two forms together, and form2 use the data of form1?

Based on your description, I suggest you not put Company combo box in the form of PFPAddress.

User doesn't need to choose value in this combo box. The Company field will be updated with the value that PFPCompany form just submitted.

I've made a similar test for your reference:

1)Form1 is used to update PFPCompany entity (in my test named testone)

2)Form2 is ued to update PFPAddress entity( in my test named testmany), in testmany entity, there's a lookup field named testone(related to testone entity)(you could see as the Company field in your issue).

3)Set the submit button's OnSelect:

SubmitForm(Form1);SubmitForm(Form2);Patch(testmanies,Form2.LastSubmit,{testone:Form1.LastSubmit})

On your side you should try:

SubmitForm(Form1);SubmitForm(Form2);Patch(PFPAddress,Form2.LastSubmit,{Company:Form1.LastSubmit})

(set form1 to update PFPCompany entity, set form2 to update PFPAddress entity)

//Please notice a form's important property named LastSubmit. It could return the last record that the form submitted just now.

 

 

 

Best regards,

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

View solution in original post

5 REPLIES 5
SKH19
Level 10

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

Hi @Chiper 

Okay, a few things to unpack here. First thing, I would be very disappointed if you went back to a cumbersome old spreadsheet, bear with me and we will get this going, at which point you will wonder how you ever got by with your old systems 🙂

 

1) Don't be scared by standard entities. If they have fields you don't want to use, then just don't use them. It seems to me like you can capture all of your data in the "Account" standard entity (in Power Apps terms, Account and Company mean the same thing). This would eliminate the need for Lookups entirely.

 

2) Have you considered a Model-driven app? For a scenario like this it would probably make more sense if your users are just filling out forms in CDS. In a Model-driven app you wouldn't have to worry about the workflow issue, since you can put quick create forms inside other forms. I know Model-driven can seem daunting at first, but I can help with that, it's really not so bad.

 

3) Don't overthink Lookups in CDS! I bet you come from a relational background like me and want to use foreign key relationships. But if you have 2 entities you want to link, just set up the relationship and CDS will handle the rest, you don't need to worry about GUIDs.

 

Community Support Team
Community Support Team

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

Hi @Chiper ,

Do you want to submit two forms together, and form2 use the data of form1?

Based on your description, I suggest you not put Company combo box in the form of PFPAddress.

User doesn't need to choose value in this combo box. The Company field will be updated with the value that PFPCompany form just submitted.

I've made a similar test for your reference:

1)Form1 is used to update PFPCompany entity (in my test named testone)

2)Form2 is ued to update PFPAddress entity( in my test named testmany), in testmany entity, there's a lookup field named testone(related to testone entity)(you could see as the Company field in your issue).

3)Set the submit button's OnSelect:

SubmitForm(Form1);SubmitForm(Form2);Patch(testmanies,Form2.LastSubmit,{testone:Form1.LastSubmit})

On your side you should try:

SubmitForm(Form1);SubmitForm(Form2);Patch(PFPAddress,Form2.LastSubmit,{Company:Form1.LastSubmit})

(set form1 to update PFPCompany entity, set form2 to update PFPAddress entity)

//Please notice a form's important property named LastSubmit. It could return the last record that the form submitted just now.

 

 

 

Best regards,

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

View solution in original post

Chiper
Level: Powered On

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

Thanks for the detailed response SKH19, especially the heads up on relational databases 😉 You were spot on that is my background!

 

As for using a model driven app I actually think I should be using a web portal as primarily my users will be accessing this from their desktop, however, I am curious. My understanding was Model Driven apps were only for customers that had Dynamics CRM? I couldn't find a way to make the web forms for data entry available to all users without also giving them full access to the Power Apps studio? 

Chiper
Level: Powered On

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

Thanks for the tip Phoebe Liu. This was exactly what I needed and it works perfectly. Although it has caused me to question how to enter data on a different form for this app but I will ask a new question for that to keep topics aligned. Thanks again for taking the time to read my thesis and respond, got my app adventure back on track as I couldn't for the life of me figure out how to solve the problem and turns out it was actually quite simple. 

SKH19
Level 10

Re: Submitting Multiple Forms When Form B References The New Record Of Form A?

@Chiper 

You don't need a Dynamics license to build Model-driven apps. Dynamics applications are just Model-driven apps that Microsoft builds, maintains and shares, with some extra background functionality. But with a Power Apps license, if your data is hosted in CDS, you can quickly and easily build your own application that looks and feels like Dynamics.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Users online (5,179)