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 / How do I update the va...
Power Apps
Unanswered

How do I update the values in a Dataverse table using gallery populated form?

(0) ShareShare
ReportReport
Posted on by 831 Moderator

I started a thread here but it seems to have gone dead. Completely understandable.

 

My form is populated when a gallery selection is made. All looks good. The problem when it comes to editing and saving back to the table. Any fields that are requires, in this case combo boxes and radio buttons, thrown an error when I submit. If i remove the requirement the form submits but those same controls overwrite the fields with nothing instead of the data populated by the gallery. I did have one combo box that did not fail. This particular combo box was using the following for Items

Distinct('TableName', 'ColumnName')

 

and using this for Update

ComboBoxName.Selected.Value

 

I've tested this with other combo boxes and it seems to fix the issue with the data not submitting. It also fixes the error messages for those data cards that required. I guess a simple fix is to do this with all combo boxes but I am not sure that is the best approach. For one, I am not sure how to update combo boxes that use 'depends on' for items like this:

 

Filter('TableName', 'ColumnName' = ComboBoxName.Selected.Value)

 

I am looking for the best approach to get all of these combo boxes to update the Dataverse table when I submit the form and prevent error messages from appearing. Suggestions?

I have the same question (0)
  • v-jefferni Profile Picture
    on at

    Hi @futr_vision ,

     

    Since all those columns are required, you'll need to use a Text or Record in Update according to the column type. For Text columns, the formula in Update could be:

    ComboBox.Selected.ColumnName

    or

    ComboBox.SelectedText.Value

     

    But for LookUp or Choices columns, they depend. Do you have such columns to update?

     

    Best regards,

  • futr_vision Profile Picture
    831 Moderator on at

    The only way I seem to be able to get this to work is if I change the Items property, for the combo boxes, to something like Distinct(TableName, 'TableColumnName') and then set the update to ComboBox.SelectedText.Value. If I go the other route there seems to be issues when that data card is required. Really no idea why. Is this expected? Is my solution the best way to fix this?

  • futr_vision Profile Picture
    831 Moderator on at

    Hmm. If I change the Update of the data card to ComboBoxName.Selected.ColumnName the value assigned to that is Blank when I load a record up from the gallery. It only changes to the value from the gallery when I reselect something from the combo box. 

  • v-jefferni Profile Picture
    on at

    Hi @futr_vision ,

     

    Sorry for the late. For your scenario, you need to modify several places of each Combo box based on the column types. Case differs due to different data source structures in Items property.

     

    If you are working on a Text column, please try below formulas:

    Items of Combo box:

    Distinct(TableName, 'TableColumnName')

    DefaultSelectedItems:

    LookUp(Distinct(TableName, 'TableColumnName'), Value = Parent.Default)

    Update of the Card:

    ComboBox.Selected.Value

     

    Best regards,

  • futr_vision Profile Picture
    831 Moderator on at

    Thanks. This works great in almost in all instances with the exception of one and that is probably because I am doing something unique.

     

    Here I have a button that hides the controls in the data card and shows others via a toggle variable. The combo box populates as expected when the record is selected in the gallery

    futr_vision_0-1706884509490.png

    This is the code on the "Add New Partner" button

     

     

    UpdateContext({varAddPartner: !varAddPartner})

     

     

    These controls become visible when the "Add New Partner" button is clicked.

    futr_vision_1-1706884534626.png

    When you enter the new partner name and click 'Add Partner' the new partner name is added to a table in Dataverse and toggles the visibility back to the original controls.

    futr_vision_2-1706884647901.png

    This is the code used on the "Add Partner" button

     

    UpdateContext({newPartner: 
    If(
     !IsBlank(TXT_AddPartnerReview.Text) && IsBlank(
     LookUp(
     Partners,
     'Partner Name' = TXT_AddPartnerReview.Text
     ).'Partner Name'
     ),
     Patch(
     Partners,
     Defaults(Partners),
     {'Partner Name' : TXT_AddPartnerReview.Text}
     )
    )});
    UpdateContext({varAddPartner: !varAddPartner});
    Reset(TXT_AddPartnerReview)

     

     

     

    Here I am back to where I started. This works fine but requires the user to interact with the combo box again and choose the new partner name that was added in the previous step. Ideally, I would want the combo box populated with the new partner name that was added.

    futr_vision_3-1706884678157.png

     

     

    The current expression I am using for DefaultSelectedItems is:

     

    LookUp(Distinct(Partners, 'Partner Name'), Value = Parent.Default)

     

     

    In another part of the app, where a new record is created, I am using this code and this populates the combo box when a new partner name is added. (Yes. There is a radio button involved in displaying the data card)

     

    If(
     Self.DisplayMode=DisplayMode.Edit && Text(RB_PartneringReview.Selected.Value) = "Yes", 
     If(
     IsBlank(newPartner),
     {CB_PartnerNameReview: Parent.Default},
     newPartner
     ), 
     Blank()
    )

     

     

    What I have above does not throw an error but it also doesn't populate the combo box. I've dropped a label in the app and set it to newPartner.'Partner Name' and it does show the new partner name I added. How could I edit this code to work with the combo box in the edit form? 

     

    NOTE: I don't think I ever mentioned that I am currently using a global variable for the Item property of the form. Could that be the reason my code doesn't work? 

     

  • futr_vision Profile Picture
    831 Moderator on at

    I think this may have solved my last issue

     

    If(
     Self.DisplayMode=DisplayMode.Edit && Text(RB_PartneringReview.Selected.Value) = "Yes", 
     If(
     IsBlank(newPartner),
     {Value: Parent.Default},
     {Value: newPartner.dk_partnername}
     ), 
     Blank()
    )

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard