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 / Canvas App button - On...
Power Apps
Answered

Canvas App button - OnSelect update Dataverse table row

(0) ShareShare
ReportReport
Posted on by 56

Hello,

 

I have a Canvas App which at the moment, has one page split in half with a form and also a datatable. The bottom half - The datatable, has a custom table created in Dataverse called "Invoice Portal" which displays an invoice in each row, but it is showing a filtered view : Filter('Invoice Portal', 'Invoice Portal (Views)'.'Awaiting Approval')

 

The top half of the page, is the Form area which has some columns. I have the DataTable set up so when users select a record on the datatable, the forms column show (or selects) the current records details. I have a button I'm intending to set up so when users have a record selected, they can click this button to approve the invoice which will then trigger flow on processes. From what I understand, DataTables can't be edited and aren't customizable? Does this mean I'm requried to use the Patch method and update the Dataverse table, which would then update the DataTables "Approval Status" to "Approved"?

 

Dataverse Table: Invoice Portal

Column Name: In Dataverse, its logical name is "be3c6_approvedstatus" - In the DataTable its field displayname is just Approved Status.

 

Would my Patch code look like:

"Patch('Invoice Portal',Defaults('Invoice Portal'),{'Approval Status':"Approved"})"

 

I can't figure out the Patch aspect when it comes to dataverse tables and a choice column.

Categories:
I have the same question (0)
  • SBax Profile Picture
    1,348 on at

    Dataverse status columns are a bit more tricky

     

    You need to say the name of the status field then the value within your patch

     

    E.g. Status (Accounts).Active would set the account to active

     

    Something like this should cover what you need 

     

    Patch('Invoice Portal',Defaults('Invoice Portal'),{'Approval Status': 'Status (Invoice Portal)'.Approved})

     

    Intellisense should be able to suggest any issues as you go, so I'd recommend typing the above as opposed to copy/paste

     

    If this doesn't work, drop me a reply, I've got a working example in an app that I can look out tomorrow when I'm at my desk (if required)

  • SBax Profile Picture
    1,348 on at

    @BAJ 

     

    as promised, here is a working example that changes the status of an account to inactive

     

    Patch(Accounts,ThisItem,{Status: 'Status (Accounts)'.Inactive})

     

    Accounts is the table

    This item refers to the item to be updated (in this case its a gallery item, so "ThisItem"

    we then pass the fields to be updated as part of the patch, here we are saying update the status, to the value of the inactive status, from the Account table's status column

     

    hope this helps

  • BridgeInbetween Profile Picture
    56 on at

    Thanks for the response, I've only been able to get back to this just now.

    I think where I was originally going wrong was not identifying the status field + value in the patch.

     

    Is this patch formula working with a choice column? it seems like this may be only a text field? would it require an additional "Value:" command? It seems like the Patch command is working, but I get an error which says the below, and it may be related to the column/field type?

     

    "does not match the expected type optionsetvalue"

  • SBax Profile Picture
    1,348 on at

    Hi @BAJ 

     

    The formula I shared is for patching a choice field (Status)

     

    Are you capturing the chosen status in your canvas app in a choice field? If so, you will need a . value at the end of the choice field name in your patch 

  • BridgeInbetween Profile Picture
    56 on at

    No I'm not capturing the chosen status. The default value of the field is empty and there's either an approve or reject choice.

     

    I've configured the Form to show that when users select a record in the DataTable, the Form generates the information for that record, by setting the Forms  Settings>Advanced>Item Field to Datatable.Selected

  • SBax Profile Picture
    1,348 on at

    Hi @BAJ 

     

    I'll build something similar in my playground environment later today and come back to you with a working formula

     

    I have a few meetings coming up, but should be able to do this in a couple of hours for you

     

  • SBax Profile Picture
    1,348 on at

    @BAJ Just had a short gap in my diary

     

    this formula seems to work for me:

     

    Patch('Invoice Portals',Defaults('Invoice Portals'),ThisItem,{'Approved Status': ThisItem.'Approved Status'})

     

    You may need to tweak this (e.g. to replace ThisItem with wherever you store you value) but aside from small changes, it should work for you

     

    Any problems, do let me know

  • BridgeInbetween Profile Picture
    56 on at

    Thanks, I was just typing out a response then my browser crashed 😞

    I've removed some additional fluff and have it stripped back to just what I need at the moment. Please see the screenshot below. When I click on the record in the DataTable, the record information is generated in the form up the top. So what I'm trying to do is when a record is selected, the button can be pressed to change the status in the Approval Status column to Approved. I'm using the below code for the OnSelect method on the button

     

    Patch('Invoice Portals',Defaults('Invoice Portals'),ThisItem,{'Approval Status': ThisItem.Approved})

     

    Where:

    Invoice Portals = Dataverse Table name

    Defaults= modifying existing row in a dataverse table

    ThisItem = (for the record that is selected?)

    Approval Status = the column I want to modify

    ThisItem.Approved = The status I want the column to be modified to?

    BAJ_0-1658845717516.png

     

  • SBax Profile Picture
    1,348 on at

    Hi @BAJ 

     

    I've reached out to a friend who thinks he has a solution. Will come back to you within the next 24 hours 

  • SBax Profile Picture
    1,348 on at

    ***removed***

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard