cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Linked product lines to a quote (scanned with AI builder)

Hi everyone,

I 'm a beginner on Powerapps (no background as developper) and I have a problem with the application I'm trying to create.
The purpose of this app is to scan quotes using the AI builder and put informations in two custom entities : Quote and Product line (One-to-Many relationship).
I get 4 fields (quote number, salesperson, Amount and adress) with AI Builder and one tab (product line) with 4 columns (product, unit price, quantity, total)  : 

  • The 4 fields are in a Submit form and it's easy to create new quote records
  • I get the information from the table (product lines) in a gallery and use the Patch function to create product line records : 
    Patch('Lignes de produits / services';
        Defaults('Lignes de produits / services');
        {
            'Libellé ' : Gallery7_1.Selected.DESCRIPTION;
            Quantité : Gallery7_1.Selected.QUANTITÉ;
            'Prix unitaire' : Gallery7_1.Selected.'PRIX UNITAIRE';
            Total : Gallery7_1.Selected.TOTAL ;
            }
    )
 
My problem is that I can't link product lines (get with the AI Builder) to the quote attached (get with the AI Builder too). I tried to do it with a Combobox to retrieve the quote but it didn't work.
 
Do you have an idea to solve my problem?

P.S. : I hope to have been clear. As you have probably noticed, English isn't my native language Smiley Wink


Screenshot : 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Linked product lines to a quote (scanned with AI builder)

Hi @F4b ,

For your first question, please consider set the DefaultMode property of the Submit form (Edit form) to following:

FormMode.New

set the OnSuccess property of the Submit form to following:

Set(
      CurrentSubmittedQuoteRecord,         /* <-- Save the submitted Quote record into a variable */
      SubmitForm.LastSubmit
);
ResetForm(SubmitForm) /* <-- Add this formula */

 

For your second question, based on the formula that you mentioned, I think there is something wrong with your formula. I have made a test on my side, please consider modify your formula as below:

ForAll(
    Gallery7_1.AllItems;
    Relate(
        CurrentSubmittedQuoteRecord.'Lignes de produits / services';
        Patch(
            'Lignes de produits / services';
            Defaults('Lignes de produits / services');
            {
                'Libellé ': LibelléTextInputBox.Text;             /* <-- Modify formula here. LibelléTextInputBox represents the Text Input box in your Gallery to display the Libellé value   */
                Quantité: QuantitéTextInputBox.Text;                   /* <-- Modify formula here. QuantitéTextInputBox represents the Text Input box in your Gallery to display the Quantité value  */
                'Prix unitaire': PrixunitaireTextInputBox.Text;         /* <-- Modify formula here. PrixunitaireTextInputBox represents the Text Input box in your Gallery to display the Prix unitaire value */
                Total: TotalTextInputBox.Text                          /* <-- Modify formula here. TotalTextInputBox represents the Text Input box in your Gallery to display the Total value */
            }
        )
    )
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

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.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Linked product lines to a quote (scanned with AI builder)

Hi @F4b ,

Could you please share a bit more about your scenario?

Do you want to relate the multiple Product Line records with the submitted one Quote record?

 

Firstly, if you want to patch all Product Line records within your Gallery (Gallery7_1) into your Product line Entity once time, please take a try with the following formula:

ForAll(
           Gallery7_1.AllItems,
           Patch(
'Lignes de produits / services'; Defaults('Lignes de produits / services'); { 'Libellé ' : DESCRIPTION; Quantité : QUANTITÉ; 'Prix unitaire' : 'PRIX UNITAIRE'; Total : TOTAL ; } ) )

More details about the ForAll function, please check the following article:

ForAll function

 

If you want to relate the multiple Product Line records with the one submitted Quote record, I think the Relate function could achieve your needs.

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

Set the OnSuccess property of the "Submit form" (Edit form, that you mentioned) to following:

Set(
      CurrentSubmittedQuoteRecord,         /* <-- Save the submitted Quote record into a variable */
      SubmitForm.LastSubmit
)

then please modify your Patch formula as below:

Relate(                                              /* <-- relate the current submitted Product Line record to the previous submitted Quote record */
       CurrentSubmittedQuoteRecord.'Lignes de produits / services', /* <-- 'Lignes de produits / services' represents the relationship betwen your Quote Entity and your Product line Entity  */
       Patch(
'Lignes de produits / services'; Defaults('Lignes de produits / services'); { 'Libellé ' : Gallery7_1.Selected.DESCRIPTION; Quantité : Gallery7_1.Selected.QUANTITÉ; 'Prix unitaire' : Gallery7_1.Selected.'PRIX UNITAIRE'; Total : Gallery7_1.Selected.TOTAL ; } ) )

Please check and see if the following article would help in your scenario:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-relate-unrelate

 

Best regards,

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.
Highlighted
Helper I
Helper I

Re: Linked product lines to a quote (scanned with AI builder)

Hi Kris Dai (@v-xida-msft),
Thank You very much for your answer, it helped me a lot !

I think you understood my problem very well : I want to scan a quote and get quote information and product lines. For that, I have to relate the multiple Product Line records with one Quote record.
However, I did what you said and I still Have issues :
 
  1. It works fine the first time but the form disappears when it's submitted. Afther that,  when I try to add a second quote, no information is displayed. Just a message "no items to display" (see Screenshot 1). I think it's may be a reset problem but I don't know how to use it (maybe on the back button?).

  2. When I scan a quote with several product lines and save them in the CDS, the correct number of records is saved (3 records for 3 product lines, for example) but each record corresponds to the first Products Line. In the same way, changes to the product line aren't taken into account (see Screenshot 1 and 2). Code ("Patch" button : on select) : 
    ForAll(
        Gallery7_1.AllItems;
        Relate(
            CurrentSubmittedQuoteRecord.'Lignes de produits / services';
            Patch(
                'Lignes de produits / services';
                Defaults('Lignes de produits / services');
                {
                    'Libellé ': Gallery7_1.Selected.DESCRIPTION;
                    Quantité: Gallery7_1.Selected.QUANTITÉ;
                    'Prix unitaire': Gallery7_1.Selected.'PRIX UNITAIRE';
                    Total: Gallery7_1.Selected.TOTAL
                }
            )
        )
    )

 

Do you have an idea to solve this two problems ?

Thanks a lot ! 🙂


Screenshot 1 :

Capture2.PNG

 

Screenshot 2 : 

Quote entity.PNG

 

Highlighted
Community Support
Community Support

Re: Linked product lines to a quote (scanned with AI builder)

Hi @F4b ,

For your first question, please consider set the DefaultMode property of the Submit form (Edit form) to following:

FormMode.New

set the OnSuccess property of the Submit form to following:

Set(
      CurrentSubmittedQuoteRecord,         /* <-- Save the submitted Quote record into a variable */
      SubmitForm.LastSubmit
);
ResetForm(SubmitForm) /* <-- Add this formula */

 

For your second question, based on the formula that you mentioned, I think there is something wrong with your formula. I have made a test on my side, please consider modify your formula as below:

ForAll(
    Gallery7_1.AllItems;
    Relate(
        CurrentSubmittedQuoteRecord.'Lignes de produits / services';
        Patch(
            'Lignes de produits / services';
            Defaults('Lignes de produits / services');
            {
                'Libellé ': LibelléTextInputBox.Text;             /* <-- Modify formula here. LibelléTextInputBox represents the Text Input box in your Gallery to display the Libellé value   */
                Quantité: QuantitéTextInputBox.Text;                   /* <-- Modify formula here. QuantitéTextInputBox represents the Text Input box in your Gallery to display the Quantité value  */
                'Prix unitaire': PrixunitaireTextInputBox.Text;         /* <-- Modify formula here. PrixunitaireTextInputBox represents the Text Input box in your Gallery to display the Prix unitaire value */
                Total: TotalTextInputBox.Text                          /* <-- Modify formula here. TotalTextInputBox represents the Text Input box in your Gallery to display the Total value */
            }
        )
    )
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

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.

View solution in original post

Highlighted
Helper I
Helper I

Re: Linked product lines to a quote (scanned with AI builder)

It worked ! 

Thank you very much !

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,375)