Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

What PowerFX command should I use to update a Parent record via a custom button?

(1) ShareShare
ReportReport
Posted on by 2

Hi everyone!

 

I do not know if I am in the right place, but I need help with writing a command in Power FX to trigger a custom button in our model-driven app in PowerApps. I searched the internet but could not find the right solution.

Scenario:

I have created a custom button in the model-driven app on the table 'Opportunity Line'. I need this button to update a toggle on the parent Opportunity when a user uses this button (set it to true). As a result, a cloud flow will be triggered.

Currently, I am using this command, but when I click the button, nothing happens:

 

Patch(
    Opportunities, // Parent entity name
    LookUp(
        Opportunities,
        Opportunity = ThisRecord.Opportunity // Match the OpportunityID in the child record with the parent
    ),
    {
        'Convert to Sample Request': true
    }

)

 

I know I am doing something wrong but I don't know what, as I am very new to Power FX commands.

Thank you!

  • Verified answer
    Inogic Profile Picture
    Inogic 402 on at
    What PowerFX command should I use to update a Parent record via a custom button?
    Hi,

    This Fx formula will not work on your scenario as it get confused to which opportunity he wants to update. Use the below Power fx formula which will update the toggle field on the parent opportunity.

    Patch(Opportunities, Self.Selected.Item.Opportunity,{Forecast:'Forecast (Opportunities)'.Yes})

    In this formula Forecast is my toggle field in the Parent Opportunity which gets updated to ‘Yes’ when clicked on the button present in the Opportunity line.
     
    Inogic Professional Services
    An expert technical extension for your techno-functional business needs
    Power Platform/Dynamics 365 CRM
    Drop an email at crm@inogic.com
    Service:  https://www.inogic.com/services/ 
    Power Platform/Dynamics 365 CRM Tips and Tricks:  https://www.inogic.com/blog/ 
  • Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    What PowerFX command should I use to update a Parent record via a custom button?
    Hi Partner,
    Do you have to use Power FX command for this purpose?
    Maybe consider using a workflow or javscript?
    About Power Fx patch function, you can refer to the following documentation:

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans