Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Reading/collecting multi-line text values into a table or collection

(3) ShareShare
ReportReport
Posted on by 235
I've got an app that uses a lookup field on a sharepoint list.
I am able to use a combobox canvas to display all of the items in the Lookup and choose multiple values.  That works.
 
I write the multiple values to a multi-line text field and the data looks like this:
 
false, NYALBBNC005B
true, NYALBBNC010
true, NYALBBNC011
true, NYALBBNC011 RASGW01
true, NYALBBNC011VZ3
true, NYALBBNC013
 
my problem is getting these values back into a collection or table or gallery where I can use the values of both fields to do some matching.  I didn't format the data as a table, initially but I've tried that and still can't get it so that I can split on the comma.  I've written this raw (as above, using table notation, shown below - can't figure it out either way)   I just need to get those values back in the app in a useable state (with column names or something)

{PatchStatus: false, MachineName: NYALBBNC104},
{PatchStatus: true, MachineName: NYALBBNC105},
{PatchStatus: false, MachineName: NYALBBNC106}     
 
The true/false values will be used to set a checkbox as either checked or not for a particular machine name (strings of characters following true or false)  So I need to be able to compare the machine names and set the checkbox accordingly.
 
Any and all help is truly appreciated.  Thank you.
Categories:
  • Suggested answer
    vipuljain03 Profile Picture
    vipuljain03 192 on at
    Reading/collecting multi-line text values into a table or collection
     
    Please click Accept as solution if my post helped you solve your issue. ✔️ This will help others find the solution to this problem. It also closes the item.

    If the content was useful in other ways, please consider giving it Thumbs Up. 👍
  • AmyF Profile Picture
    AmyF 235 on at
    Reading/collecting multi-line text values into a table or collection
    Attempting to mark your response as answer... not sure how to do that, I guess
  • AmyF Profile Picture
    AmyF 235 on at
    Reading/collecting multi-line text values into a table or collection
    Never mind, I just trim it off after collecting.  Thanks again for your example.  Very clear.  You're a good teacher.
  • AmyF Profile Picture
    AmyF 235 on at
    Reading/collecting multi-line text values into a table or collection
    FYI I did notice that the data written to SharePoint had a trailing blank line, so I deleted that and it seems to be the problem.  Given your code, what's the best way to eliminate that extra line?  If you have an opinion, that is.
     
    Thanks,
    Amy
  • AmyF Profile Picture
    AmyF 235 on at
    Reading/collecting multi-line text values into a table or collection
    Thank you so much Vipul,
     
    I am sure your solution is correct but I have one remaining problem.  In my ParsedData collection I'm getting an extra line with just "false" on it.  
    A little extra info:  I choose these machines from a lookup column on sharepoint that is connected to a modern combobox canvas.  As I select them they appear in a gallery on the same page whose items property is the combobox canvas DefaultSelectedItems  is the sharepoint lookup column.  The gallery has only a checkbox (PatchStatus) and a text field for the machine name.  It's Default is Parent.Default.  The extra line doesn't show up in the combobox Canvas nor in the Gallery nor on the data I write to SharePoint.  Originally I write the rawPatchStatus field to SharePoint in a ForAll loop.
    But my ParsedData collection looks like this:
    I can't tell where that extra line is coming from.  Have you seen this before?  I'm sure it's an anomaly on my side but I can't find it.
    Any suggestions or thoughts on this?
    Thanks again, 
    -Amy
  • Verified answer
    vipuljain03 Profile Picture
    vipuljain03 192 on at
    Reading/collecting multi-line text values into a table or collection
    I think you need to transform the stored data in your multi-line text field into a usable table format in Power Apps. This can be done by parsing the raw text, splitting it into rows, and then further splitting each row into columns.
     
    Please find below my solution:
     
    1. I created a multi-line text field in a SharePoint Online list. Field name is TestMLOT (item ID is 9), as shown below.
     
     
    2. In Power Apps, I added a button and set some variable and finally created a Collection (ParsedData)
     
     
    OnSelect property of Button:
    Set(RawData,LookUp('App Sharing',ID=9).TestMLOT);
    Set(RowCollection,Split(Text(RawData),Char(10)));
    
    Set(SingleRow, First(RowCollection).Value);
    Set(SplitResult, Split(SingleRow, ","));
    
    Set(PatchStatus, Trim(First(SplitResult).Value));
    Set(MachineName, Trim(Last(SplitResult).Value));
    
    ClearCollect(
        ParsedData,
        ForAll(
            RowCollection,
            {
                PatchStatus: If(
                    Trim(First(Split(Value, ",")).Value) = "true",
                    true,
                    false
                ),
                MachineName: Trim(Last(Split(Value, ",")).Value)
            }
        )
    );
    Split function to create a collection of rows based on line breaks.
    I splitted each row into two parts (PatchStatus and MachineName).
     
    3. This collection (ParsedData)I used in Items property of the Gallery. Added a checkbox in the gallery and set its Default property to ThisItem.PatchStatus.
     
    Summary:
    1. Step 1: Split the raw data into individual rows (RowCollection)
    2. Step 2: Split each row into two parts (PatchStatus and MachineName).
    3. Step 3: Trim the parts and map them to PatchStatus and MachineName
     
    -------------------------------------------------------------------------------------------------
    If this reply helped you, please mark this reply as suggested answer ✔️ and give it a like 👍to help others in the community find the answer too!
     
    Thanks,
    Vipul

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard