cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JonasH
Helper II
Helper II

Save data from Gallery in collection

Hey,
I want to save data from a gallery from outside the gallery.

Please see the picture on the right.2019-10-25 11_47_57-QC365 - Saved (Unpublished) - PowerApps.png

I want to save the Textinput and the number on the right (61, 62...).

To achive this I tried the following statement:

ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: Gallery2.AllItems.CheckOrderLineId,
        ActualData : Gallery2.AllItems.TextInput3
    }
)
);

But the data is stored not as I want.

Powerapps saved all Textinputs and numbers in every row.

 

 

2019-10-25 11_53_09-QC365 - Saved (Unpublished) - PowerApps.png

Thanks for your help

Jonas

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @JonasH ,

Do you want to save your Gallery Items data into a collection?

 

Based on the formula you provided, I think there is something wrong with it. Please consider modify your formula as below:

Clear(tempCollection);   /* <-- Add this formula to get rid of duplicated records in this tempCollection */
ForAll(
Gallery2.AllItems, Collect( tempCollection, { CheckOrderLineId: ID, ActualData : TextInput3.Text } ) );

or

Clear(tempCollection); /* <-- Add this formula to get rid of duplicated records in this tempCollection */
ForAll( Gallery2.AllItems, Collect( tempCollection, { CheckOrderLineId: Value(IDLabel.Text), ActualData : TextInput3.Text } ) );

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
mdevaney
Super User III
Super User III

@JonasH 

Looking at your code I can see you are saving the entire column to the collection.  The code Gallery2.AllItems.your_field saves a single column table.

 

ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: Gallery2.AllItems.CheckOrderLineId,
        ActualData : Gallery2.AllItems.TextInput3
    }
)
);

 

To save only the current item try this instead

 

ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: Gallery2[@CheckOrderLineId],
        ActualData : TextInput3.Text
    }
)
);

Let me know if there are any questions

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Hey @mdevaney 

thanks for your help.

Meanwhile the "CheckOrderLineId" changed to "ID" but the adjusted code doesnt work.

ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: Gallery2[@ID],
        ActualData : TextInput3.Text
    }
)
);2019-10-25 16_41_32-Window.png

 

2019-10-25 16_40_56-Window.png

 

I may be to stupid momentarily, please excuse.

 

I will be able to reply in about 2 days

 

Have a nice weekend

Jonas

@JonasH 

Before you go can you try these instead and let me know the result? I was trying to use Gallery2[@ID] in case Gallery2.AllItems and tempCollection both had an ID column.  Perhaps my snytax was wrong.

 

ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: Gallery2.ID,
        ActualData : TextInput3.Text
    }
)
);
ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        CheckOrderLineId: ID,
        ActualData : TextInput3.Text
    }
)
);

Hi @JonasH ,

Do you want to save your Gallery Items data into a collection?

 

Based on the formula you provided, I think there is something wrong with it. Please consider modify your formula as below:

Clear(tempCollection);   /* <-- Add this formula to get rid of duplicated records in this tempCollection */
ForAll(
Gallery2.AllItems, Collect( tempCollection, { CheckOrderLineId: ID, ActualData : TextInput3.Text } ) );

or

Clear(tempCollection); /* <-- Add this formula to get rid of duplicated records in this tempCollection */
ForAll( Gallery2.AllItems, Collect( tempCollection, { CheckOrderLineId: Value(IDLabel.Text), ActualData : TextInput3.Text } ) );

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@mdevaney@v-xida-msft 

Thanks for your helpfull replys.

Your solutions worked well.

I used the code below (dont be confused cause of other line names):

Clear(tempCollection);
ForAll(Gallery2.AllItems,
Collect(
    tempCollection,
    {
        ID: ID,
        measuredSize: Value(TextInput3.Text)
    }
)
);

My next step is to update the measuredSize to a SQL record with the correspond ID.

 

Thanks for your help.

 

Have a nice day ^-^

Jonas

@mdevaney@v-xida-msft 

I have another question.

To save the data in a collection was just a bypass of saving the data in an SQL table.

I thought it might be easier to save the data in a collection before updating a SQL table column with the specific ID.

Unfortunately it only work with a hardcoded ID.
Please take a look on the code below:

 

UpdateIf('[qc365].[W_InspectionTaskPosition]', ID = 87, {measuredSize: Value(TextInput3.Text)})

The best result is, to get the current ID of a Forall statement.

I also tried to get the data from the collection (remember the bypass).

 

Thanks for your help.

Jonas

@JonasH 

You might want to close this thread and post as a new question so others will take a look.  I don't know the answer here.

@mdevaney Okay, I close this thread.

Have a nice day.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,100)