web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

PowerFx Issue - Child Records not being created

(0) ShareShare
ReportReport
Posted on by 15

Hi Community, 

I am digging into PowerFx in Command Bar within Model Driven Apps doing a clone of parent record (Quote) and child records (Quote Lines): 

pastedimage1678489032789v1.png

I am using a With statement to capture the newly created Quote guid to reference in the Quote LInes patch statement: 

With({
     quote_recid:
      Patch(Quotes,
      Defaults(Quotes),
       {
          Name: "Copy of" & Self.Selected.Item.Name,
          'Potential Customer (_customerid_value)': Self.Selected.Item.'Potential Customer (msdyn_account)',
          'Potential Customer (msdyn_account)': Self.Selected.Item.'Potential Customer (msdyn_account)',
           'Primary Contact': Self.Selected.Item.'Primary Contact',
          'Price List': Self.Selected.Item.'Price List',
          Currency: Self.Selected.Item.Currency,
          'Work Order Type': Self.Selected.Item.'Work Order Type',
          'Payment Terms': Self.Selected.Item.'Payment Terms'
        }
      )
    },

//Clone Child Records
Patch('Quote Lines',
  ForAll(Self.Selected.Item.'Quote Lines' As quoteproducts,
    Patch(
      Defaults('Quote Lines'),
      {
         Quote: quote_recid,
        'Quote Product': quoteproducts.'Quote Product',
        Quantity: quoteproducts.Quantity,
        'Price Per Unit': quoteproducts.'Price Per Unit',
        Unit: quoteproducts.Unit,
        'Product type': quoteproducts.'Product type',
        'Sequence Number': quoteproducts.'Sequence Number'

                        }
                      )
                     )
                    );

Notify("Quote Copy of " & Self.Selected.Item.Name & " and its lines have been cloned. Please open the records and update the necessary fields.");
);
Within PowerFX, it does not show any errors so I am not sure where it is erroring out. I have a case open with Microsoft but waiting to hear back. 
My copy of the Quote gets created and my notification inside Sales Hub also works. 
Something is wrong with my //Clone Child Records. 
Any peer review here of my code would be appreciated or if there is another approach I could take. 
Thank you!
I have the same question (0)
  • Verified answer
    Steve Zhao2 Profile Picture
    on at

    Hi haciendo_olas,

    Based on my test, this is due to some required columns (Name and Property Configuration) don't have value. Please try this:

    With(
        {
            QuoteId: Patch(
                Quotes,
                Defaults(Quotes),
                {
                    Name: "Copy of" & Self.Selected.Item.Name,
                    Currency: Self.Selected.Item.Currency,
                    'Price List': Self.Selected.Item.'Price List',
                    'Potential Customer (_customerid_value)': Self.Selected.Item.'Potential Customer (msdyn_account)',
                    'Potential Customer (msdyn_account)': Self.Selected.Item.'Potential Customer (msdyn_account)'
                }
            )
        },
    //Clone Child Records
            ForAll(
                Self.Selected.Item.'Quote Lines' As quoteproduct,
                Patch('Quote Lines',
                    Defaults('Quote Lines'),
                    {
                        Quote: QuoteId,
                        'Existing Product': quoteproduct.'Existing Product',
                        Quantity: quoteproduct.Quantity,
                        'Price Per Unit': quoteproduct.'Price Per Unit',
                        Unit: quoteproduct.Unit,
                        'Product type': quoteproduct.'Product type',
                        'Sequence Number': quoteproduct.'Sequence Number',
                        Name:quoteproduct.Name,
                        'Property Configuration':quoteproduct.'Properties Configuration'
                        
                    }
                )
            );
        
        Notify("clone done");
    );
    


    And this is my test result:

    pastedimage1678695905748v1.png

  • c_edouarde Profile Picture
    15 on at

    Hi Steve,

    Thanks for the help! You were correct, I was missing required fields Name , Property config., and Product Type and it worked like a charm.

    Appreciate the support!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans