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 / Set default value for ...
Power Apps
Unanswered

Set default value for column collection

(0) ShareShare
ReportReport
Posted on by 36
Hi,
 
 
I have the collection as below picture, Material, Lot and Expiry Date are taken from splitting the QR Code column. I have problem with saving the data for these three column Material, Lot and Expiry Date collection.
 
 
 
 
 
 
The Default tab of Material column is below picture, and I put onchange value also.
 
 
But that value is not taken to collection. Please help me fix this.
 
 
I have the same question (0)
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Hi @MaiLe
    Firstly you have four values in there and have only stated three fields, but you will get the idea from the code below. Also that date is going to come out as a string and you will have some further complexity getting dd/mm/yyyy format back into a date field.
    With(
       {
          _Item:
          Split(
             ThisItem.QRCode,
             "#"
          )
       },   
       Patch(
          colRecord,
          ThisItem,
          {
             Material: First(_Item).Value,
             Lot: Index(_Item, 2).Value,
             ExpiryDate: Last(_Item).Value
          }
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee
  • MaiLe Profile Picture
    36 on at
     
    Could you please explain to me more where I can put that code?
     
    Thank you.
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Wherever you have the current Patch code you posted.
  • MaiLe Profile Picture
    36 on at
     
     
     
     
     
    Default property
     
    My collection:
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Sorry, I am unclear on your last post - it is saving the values from the QR code to your data source. Only you would know where you are doing this.
  • MaiLe Profile Picture
    36 on at
     
    I put the OnChange property as you advised, but I saw the value took for Material is still blank in collection.
     
    My flow is below:
     
    I create a collection with 4 collumn: QR code, Material, Lot, Expiry date. The Material, Lot, Expiry date value are taken from the QR code value splitting, I'd like to record them in the collection. The property I put for these column are Default, OnChange as picture in my previous comment.

    Please help to advise. Thank you.
  • pawelbakan Profile Picture
    12 on at
    If you have your QR codes in data source (like Sharepoint list or Excel) and you load them into your app, then you can use this function:
     
    ClearCollect(col_record, AddColumns(DataSource, Material, First(Split(ThisRecord.QRCode, "#")).Value, Lot, Index(Split(ThisRecord.QRCode, "#"), 2).Value))
    
    You can add With from previous answer before AddColumns function if you have more than 2 values to add.
     
    If your app has different functionality, then you have to explain it:
     
    What is data source of your QR codes? How do you create your collection? Can app user change QR code?
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Now you have posted a different QR code format - if you used this code
    With(
       {
          _Item:
          Split(
             ThisItem.QRCode,
             "#"
          )
       },   
       Patch(
          colRecord,
          ThisItem,
          {
             Material: First(_Item).Value,
             Lot: Index(_Item, 2).Value,
             ExpiryDate: Index(_Item, 4).Value
          }
       )
    )
    on this QR Code
    • Material would be abc
    • Lot would be def
    • ExpiryDate would be 23/07/2024 (but as I mentioned, there is more work if you are trying to send it to a Date field)
    I am assuming here that Material and Lot are Text columns
  • MaiLe Profile Picture
    36 on at
     
     
     
    Yes sir, Material and Lot are Text.
    I have changed your code followed the QR code so the On change property for QR text input will be below.
     
     
     
    The collection is still missing. Please help to advise. Thank you.
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at
    Then the only remaining possibility is the reference to ThisItem, so try this - I also assume you are patching back to a date field
    With(
       {
          _Item:
          Split(
             ThisItem.QRCode,
             "#"
          )
       },   
       Patch(
          colRecord,
          LookUp(
             colRecord,
             QRCode = ThisItem.QRCode
          ),
          {
             Material: First(_Item).Value,
             Lot: Index(_Item, 2).Value,
             ExpiryDate: 
             With(
                {
                   _Data:
                   Split(
                      Index(_Item, 4).Value,
                      "/"
                   )
                },
                Date(
                   Last(_Data).Value,
                   Index(_Data, 2).Value,
                   First(_Data).Value
                )
    ​​​​​​​         )
          }
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps   

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