Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Update Button for Multiple Choice

Posted on by 372

Hi,

I have this formula on button:

ClearCollect(
ToUpdateCollection,
Filter(
'WELDER LOG REGISTER',
'Joint Number' = ThisItem.'Joint Number',
'Production Order Induk' = ProdInduk.Text
)
);
ForAll(
ToUpdateCollection,
Patch(
'WELDER LOG REGISTER',
ThisRecord,
{'Repair by': Welder.SelectedItems}
)
)

 

But, when I click button, previous value in 'Repair by' will be replace to the new one. I want, when I click, the new value will be appear side by side with the previous value. 

Repair by is choice column type (can multiple choice). How to do it? Thankyou!

  • Pro_User_365 Profile Picture
    Pro_User_365 546 on at
    Re: Update Button for Multiple Choice
    The error in your formula arises because you're trying to concatenate a text field with a table of selected items directly. In PowerApps, you must first convert the table of selected items into a string before concatenating.

    Here's how to correct the formula:

    Firstly, ensure that Welder.SelectedItems actually contains the text values you want to append. If Welder.SelectedItems is a table with a column named, for instance, Value, which holds the choice values, you would need to convert this to a text string.

    The corrected formula should look like this:

     

     

     

    ForAll(
     ToUpdateCollection,
     Patch(
     'WELDER LOG REGISTER',
     ThisRecord,
     {
     'Repair by': Concat(ThisRecord.'Repair by', Value & ";") & Concat(Welder.SelectedItems, Value & ";")
     }
     )
    )

     

     

    In this formula, Concat function is used instead of Concatenate. Concat takes a table and a formula and returns a text result where the formula has been evaluated for each record in the table, and the results are concatenated together.

    This should append the values from Welder.SelectedItems to the existing 'Repair by' field as a text string, with each value separated by a semicolon. Adjust the column name Value to the actual column name from Welder.SelectedItems that contains the choice values you want to append.

     
     
     
  • firda59 Profile Picture
    firda59 372 on at
    Re: Update Button for Multiple Choice

    Hi @Pro_User_365 

     

    I just tried that formula, still error:

    firda59_1-1701305251500.png

     

  • Pro_User_365 Profile Picture
    Pro_User_365 546 on at
    Re: Update Button for Multiple Choice

    @firda59 , 

    It seems there might have been a misunderstanding with the previous formula. The Concatenate function should merge text values, not Choice fields directly. You need to ensure that you're manipulating the text of the selected items, not the Choice field objects themselves. Here's a revised approach:

    1. Extract the text from the selected items in the Welder.SelectedItems collection.
    2. Create a new collection or text string that includes both the old and new 'Repair by' values.
    3. Use that collection or string to update the 'Repair by' field with the Patch function.

      For example, assuming Welder.SelectedItems returns a table of records with a text field, you might need something like this:

      ForAll(
       ToUpdateCollection,
       Patch(
       'WELDER LOG REGISTER',
       ThisRecord,
       {'Repair by': ThisRecord.'Repair by' & "; " & Concat(Welder.SelectedItems, Value & ";")}
       )
      )

      In this formula, Concat is used to create a string of all the selected items' values, separated by semicolons, which are then appended to the existing 'Repair by' value.

      Remember to replace Value with the actual name of the field in the Welder.SelectedItems that holds the text you want to append.

      This approach should append the new selections to the existing 'Repair by' field content, separated by semicolons. Make sure to test the formula and adjust the field names according to your actual data schema.

     

  • firda59 Profile Picture
    firda59 372 on at
    Re: Update Button for Multiple Choice

    Hi @Pro_User_365 ,

     

    I used that formula, and this is the result:

    firda59_0-1701250155129.png

     

    Is there any solution? thankyou

  • Pro_User_365 Profile Picture
    Pro_User_365 546 on at
    Re: Update Button for Multiple Choice

    Hi @firda59 ,

    To modify your PowerApps formula so that the new 'Repair by' value appears alongside the previous value in a choice column, you need to concatenate the existing values with the new selection. Your updated formula should look something like this:

    ForAll(
    ToUpdateCollection,
    Patch(
    'WELDER LOG REGISTER',
    ThisRecord,
    {'Repair by': Concatenate(ThisRecord.'Repair by', ";", Welder.SelectedItems)}
    )
    )

    In this revised formula, `Concatenate` is used to join the existing 'Repair by' values with the new selection from `Welder.SelectedItems`. The semicolon (";") is a typical delimiter for separating items in a string, but you should adjust it based on how your choice column manages multiple values. This will ensure that when you click the button, the new value is added next to the existing ones, rather than replacing them.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard