cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Phineas
Community Champion
Community Champion

Save Multiple Gallery Items to Collection and SharePoint List

I am building an app with 'Offline' capability.

I am able to collect and then save the data back to SharePoint.

Some of the saved data is coming from a gallery. The user has
the ability to create one or multiple items in the gallery.

When I collect and save the data only one item from the gallery
is being stored in the collection and saved back to the SharePoint
list.

How do I update my formulas (below) so that all the items in the
gallery are stored in the collection as records and saved as records
back to the SharePoint list?

My 'Save Collection' button has -
If
(Invoice_Type_DataCardValue.Text = "Drop",
Collect(colDropData,
    {    
         //Gallery Fields -
         colDrop_Activity:
Activity_ComboBox.Selected.Value,
         colDrop_Activity_Rate: Value(Activity_Rate_Fld.Text),
         colDrop_Activity_Quantity: Value(Activity_Quantity_Fld.Text),
         colDrop_Activity_Total: Value(Activity_Total_Fld.Text),
         //Form Fields -
         colDrop_Technician_Name: Tech_Name_ComboBox_DataCardValue.Selected.Full_Name,
         colDrop_Technician_ID_Number: Technician_ID_Number_DataCardValue.Text,
         colDrop_Customer_Name: Customer_Name_Dropdown.Selected.Value,
         colDrop_Customer_Account_Number: Customer_Account_Number_DataCardValue.Text,
         colDrop_Invoice_Type: Invoice_Type_DataCardValue.Text,
       }
    )
);


My 'Submit Data' button has -

If(CountRows(colDropData) > 0,
ForAll(colDropData,
    Patch(Drop_Backup_List,
    Defaults(Drop_Backup_List),
    {    
          //Gallery Fields -
         Activity: colDrop_Activity,
         Activity_Rate: colDrop_Activity_Rate,
         Activity_Quantity: colDrop_Activity_Quantity,
         Activity_Total: colDrop_Activity_Total,
         //Form Fields -
         Technician_Name: colDrop_Technician_Name,
         Technician_ID_Number: colDrop_Technician_ID_Number,
         Customer_Name: colDrop_Customer_Name,
         Customer_Account_Number: colDrop_Customer_Account_Number,
         Invoice_Type: colDrop_Invoice_Type
       }
       )
);


Phineas_0-1714763586831.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Edited Reply:
Okay, looks like I got it; I finally got the formula provide more than one gallery item with the same base form data, as desired.

Phineas_1-1714843582531.png

colDropData collectin formula. I'm not sure if this is properly formatted, but it's working.

If(Invoice_Type_DataCardValue.Text = "Drop",
   ForAll(Activity_Gallery.AllItems,
      Collect(colDropData,
      {
         //Form Data
         colDrop_Location: Location_Dropdown.Selected.Value,
         colDrop_Technician_Name: Tech_Name_ComboBox_DataCardValue.Selected.Full_Name,
         colDrop_Technician_ID_Number: Technician_ID_Number_DataCardValue.Text,
         colDrop_Customer_Name: Customer_Name_Dropdown.Selected.Value,
         colDrop_Customer_Account_Number: Customer_Account_Number_DataCardValue.Text,
         colDrop_Invoice_Type: Invoice_Type_DataCardValue.Text,
         colDrop_Title: Work_Order_Number_DataCardValue.Text,
         colDrop_Substation: Substation_DataCardValue_ComboBox.Selected.Sub_Feeder_Name,
         colDrop_Bill_To: Bill_To_DataCardValue.Text,
         colDrop_Work_Date: Work_Date_DataCardValue.SelectedDate,
         colDrop_Work_Ending_Date: Week_Ending_Date_DataCardValue.SelectedDate,
         colDrop_Tap: Tap_DataCardValue.Text,
         colDrop_Tap_Pole_Number: Tap_Pole_Number_DataCardValue.Text,
         colDrop_Light_Level_at_NID: Light_Level_DataCardValue.Text,
         colDrop_Job_JHA_Completed: JHA_Checkbox.Value,
         colDrop_Role: Role_DataCardValue.Text,
          //Gallery Data
         colDrop_Activity: Activity_ComboBox.Selected.Value,
         colDrop_Activity_Rate: Value(Activity_Rate_Fld.Text),
         colDrop_Activity_Quantity: Value(Activity_Quantity_Fld.Text),
         colDrop_Activity_Total: Value(Activity_Total_Fld.Text),
         colDrop_Activity_Consumable: Consumable_Fld.Text,
         colDrop_Activity_Consumed_Qty: Consumed_Qty_Fld.Text,
         colDrop_Activity_Consumed_Description: Consumed_Description_Fld.Text,
         colDrop_Activity_Unit: Consumed_Unit_Fld.Text,
         colDrop_Activity_Waste_Qty: Waste_Qty_Fld.Text,
         colDrop_Activity_Waste_Description: Waste_Description_Fld.Text,
         colDrop_Activity_Waste_Unit: Waste_Unit_Fld.Text
       }
    ) )
);

I now have the following formula in my 'Submit Data' (to SharePoint) button. All of the data is being patched as desired.
If(CountRows(colDropData) > 0,
   Patch(Drop_Backup_List,
   ForAll(
    colDropData,
    {    
         Activity: colDrop_Activity,
         Activity_Rate: colDrop_Activity_Rate,
         Activity_Quantity: colDrop_Activity_Quantity,
         Activity_Total: colDrop_Activity_Total,
         Technician_Name: colDrop_Technician_Name,
         Technician_ID_Number: colDrop_Technician_ID_Number,
         Customer_Name: colDrop_Customer_Name,
         Customer_Account_Number: colDrop_Customer_Account_Number,
         Invoice_Type: colDrop_Invoice_Type,
         Title: colDrop_Title,
         Location: colDrop_Location,
         Substation: colDrop_Substation,
         Bill_To: colDrop_Bill_To,
         Work_Date: colDrop_Work_Date,
         Week_Ending_Date: colDrop_Work_Ending_Date,
         Tap: colDrop_Tap,
         Tap_Pole_Number: colDrop_Tap_Pole_Number,
         Light_Level_at_NID: colDrop_Light_Level_at_NID,
         Job_JHA_Completed: colDrop_Job_JHA_Completed,
         Role: colDrop_Role
}
       
      )
   )
 
;

View solution in original post

10 REPLIES 10
WarrenBelz
Most Valuable Professional
Most Valuable Professional

@Phineas ,

I am assuming here that your collection code works and colDropData contains the expected data.

If(
   CountRows(colDropData) > 0,
   Patch(
      Drop_Backup_List,
      ForAll(
         colDropData As _Data,
         {    
            Activity: _Data.colDrop_Activity,
            Activity_Rate: _Data.colDrop_Activity_Rate,
            Activity_Quantity: _Data.colDrop_Activity_Quantity,
            Activity_Total: _Data.colDrop_Activity_Total,
            Technician_Name: _Data.colDrop_Technician_Name,
            Technician_ID_Number: _Data.colDrop_Technician_ID_Number,
            Customer_Name: _Data.colDrop_Customer_Name,
            Customer_Account_Number: _Data.colDrop_Customer_Account_Number,
            Invoice_Type: _Data.colDrop_Invoice_Type
         }
      )
   )
);

 

Please click Accept as solution 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 Thumbs Up.

MVP (Business Applications)   Visit my blog Practical Power Apps

Yes, I have confirmed - several times, the current formula is storing a single line of data to the collection add patching said line of data to the list.

 

I am also building an regular "online" version of the mobile app.

 

How would the formula change where there is no collection, and the user 

needs to patc,h one or multiple lines of form/gallery data directly to the list (no collection)?

WarrenBelz
Most Valuable Professional
Most Valuable Professional

@Phineas ,

You asked how to patch all the records of a collection colDropData to new records in your SharePoint List Drop_Backup_List - How do I update my formulas (below) so that all the items in the gallery are stored in the collection as records and saved as records back to the SharePoint list?

I believe what I posted will do that so firstly, does it work for you ? There are some dangers with posting direct from the gallery depending on your structure.

 

Please click Accept as solution 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 Thumbs Up.

MVP (Business Applications)   Visit my blog Practical Power Apps

My apologies, I miss read your first reply.

No, my collection DOES NOT contain ALL of the data.

Here is an example of the colDropData collection.

The form being stored to the collection has one item (the form will always have one item),

The gallery has two items, yet the colDropData collection stored one of the gallery items, the last item entered in the gallery. 

Phineas_0-1714839351465.png

Phineas_1-1714839466686.png

 

Edited Reply:
Okay, looks like I got it; I finally got the formula provide more than one gallery item with the same base form data, as desired.

Phineas_1-1714843582531.png

colDropData collectin formula. I'm not sure if this is properly formatted, but it's working.

If(Invoice_Type_DataCardValue.Text = "Drop",
   ForAll(Activity_Gallery.AllItems,
      Collect(colDropData,
      {
         //Form Data
         colDrop_Location: Location_Dropdown.Selected.Value,
         colDrop_Technician_Name: Tech_Name_ComboBox_DataCardValue.Selected.Full_Name,
         colDrop_Technician_ID_Number: Technician_ID_Number_DataCardValue.Text,
         colDrop_Customer_Name: Customer_Name_Dropdown.Selected.Value,
         colDrop_Customer_Account_Number: Customer_Account_Number_DataCardValue.Text,
         colDrop_Invoice_Type: Invoice_Type_DataCardValue.Text,
         colDrop_Title: Work_Order_Number_DataCardValue.Text,
         colDrop_Substation: Substation_DataCardValue_ComboBox.Selected.Sub_Feeder_Name,
         colDrop_Bill_To: Bill_To_DataCardValue.Text,
         colDrop_Work_Date: Work_Date_DataCardValue.SelectedDate,
         colDrop_Work_Ending_Date: Week_Ending_Date_DataCardValue.SelectedDate,
         colDrop_Tap: Tap_DataCardValue.Text,
         colDrop_Tap_Pole_Number: Tap_Pole_Number_DataCardValue.Text,
         colDrop_Light_Level_at_NID: Light_Level_DataCardValue.Text,
         colDrop_Job_JHA_Completed: JHA_Checkbox.Value,
         colDrop_Role: Role_DataCardValue.Text,
          //Gallery Data
         colDrop_Activity: Activity_ComboBox.Selected.Value,
         colDrop_Activity_Rate: Value(Activity_Rate_Fld.Text),
         colDrop_Activity_Quantity: Value(Activity_Quantity_Fld.Text),
         colDrop_Activity_Total: Value(Activity_Total_Fld.Text),
         colDrop_Activity_Consumable: Consumable_Fld.Text,
         colDrop_Activity_Consumed_Qty: Consumed_Qty_Fld.Text,
         colDrop_Activity_Consumed_Description: Consumed_Description_Fld.Text,
         colDrop_Activity_Unit: Consumed_Unit_Fld.Text,
         colDrop_Activity_Waste_Qty: Waste_Qty_Fld.Text,
         colDrop_Activity_Waste_Description: Waste_Description_Fld.Text,
         colDrop_Activity_Waste_Unit: Waste_Unit_Fld.Text
       }
    ) )
);

I now have the following formula in my 'Submit Data' (to SharePoint) button. All of the data is being patched as desired.
If(CountRows(colDropData) > 0,
   Patch(Drop_Backup_List,
   ForAll(
    colDropData,
    {    
         Activity: colDrop_Activity,
         Activity_Rate: colDrop_Activity_Rate,
         Activity_Quantity: colDrop_Activity_Quantity,
         Activity_Total: colDrop_Activity_Total,
         Technician_Name: colDrop_Technician_Name,
         Technician_ID_Number: colDrop_Technician_ID_Number,
         Customer_Name: colDrop_Customer_Name,
         Customer_Account_Number: colDrop_Customer_Account_Number,
         Invoice_Type: colDrop_Invoice_Type,
         Title: colDrop_Title,
         Location: colDrop_Location,
         Substation: colDrop_Substation,
         Bill_To: colDrop_Bill_To,
         Work_Date: colDrop_Work_Date,
         Week_Ending_Date: colDrop_Work_Ending_Date,
         Tap: colDrop_Tap,
         Tap_Pole_Number: colDrop_Tap_Pole_Number,
         Light_Level_at_NID: colDrop_Light_Level_at_NID,
         Job_JHA_Completed: colDrop_Job_JHA_Completed,
         Role: colDrop_Role
}
       
      )
   )
 
;

WarrenBelz
Most Valuable Professional
Most Valuable Professional

@Phineas ,

You marked your own post as a solution to a different question to what you asked again . . .
I wanted to know if the solution provided to the posted question worked before proceeding (possibly in error) assuming it did with something involving the gallery. I am in a different time zone and just got to this.

Regarding storing data to the collection, I took what you sent and worked it over a bit. The initial lines had to be edited and rearranged, as shown in the previous post.

Regarding saving the collected data to the SharePoint list, yes - after I removed the "As _Data", your formula did work.

WarrenBelz
Most Valuable Professional
Most Valuable Professional

@Phineas ,

You do not need to remove  As _Data - the structure is correct. You have been posting here a long time (many years), but I still seem to struggle providing you with solutions to the initial question you post. 

1. I thank you for your "years" of patient assistance.

 

2. I've always asked - whomever would help, to understand I may struggle processing what you know to be obvious; yet I am not deterred.

 

3. I tried the formula with thr "As _Data", Power Apps kicked back an error.

 

Taking it out and reconfiguring the formula got it to work.🤷🏾‍♂️

 

It is never my intent to waste anyone's time, and I am thankful for the vastness of the knowledge base in this community.🙏🏾

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (505)