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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch formula to write...
Power Apps
Unanswered

Patch formula to write Opportunity Products into CDS

(0) ShareShare
ReportReport
Posted on by 10

Hello All, 

I have a canvas app embedded in model driven app which is basically listing all the products from product catalog. Upon selecting some of the products from the list, I'm updating a collection with all those selected products. Now, I've added another button to patch those collection items from Canvas App to Model Driven app as opportunity line items/opportunity products. (I'm passing Opportunity ID from the ModelDrivenFormIntegration and trying to use that in the patch function as an opportunityid)

But Patch formula for Opportunity Products if not working on canvas apps. I'm getting "The Specified Column 'OpportunityProduct_AsyncOperation' does not exist" error upon writing the below formula.

Patch(Collection, Defaults('Opportunity Lines'),{quantity:CQuantity})

Can anyone tell me how to write a patch formula to write Opportunity Products from Canvas app and add them as line items under an Opportunity.

Thanks,

Satya

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @satya3999 :

    Could you check the specific field name('Opportunity Lines') in your collection?

    Could you tell me whether the 'Collection' and 'Opportunity Lines' have the same data structure? (Same fields, same data type……)

    I assume that the data structure of collection and'Opportunity Lines' are different.

    Firstly,let me explain why you encounted this problem.

    The second parameter of the Patch function, which represents the BaseRecord.The new record will be added to the target data source according to the BaseRecord data structure. In other words, if BaseRecord has a "business opportunity line" field, this field will be automatically added to the new record even if it is not set in the new record(The third parameter). Therefore, if this field does not exist in the data source, the data structure of the data source and the new record does not match, the app will report an error.

    Finally,Please try this code:

     

    Patch(Collection, Defaults('Collection'),{quantity:CQuantity})

     

    Best Regards,

    Bof

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard