cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mperez84
Helper I
Helper I

On submit last item is empty

Looking for a little help with this one.

 

 Onselect of a submit button everything gets submitted all but  last item from the collection. Attached is the formula I'm using for the submit button. 

 

Does anyone have a fix for this? 

 

11 REPLIES 11
WarrenBelz
Super User III
Super User III

Hello @mperez84 ,

How do you form the variable downingid and what is the field type in the data source?

Hi @WarrenBelz

The “Downingid” is being collected from an SharePoint list as a single column that column is a single line text field. The collection is set to collect from the gallery base on the users selections.
GarethPrisk
Super User II
Super User II

A few things to note from your screenshot.

  • The ForAll function appears syntactically correct, and should Patch each row from the collection, back to SharePoint
    • I assume you intend for each 'Asset Request' to have the fixed Trade Show Title value at run-time
    • See below regarding disambiguating the destination column downingid from the collection column of the same name
  • Not sure why you have the SubmitForm, NewForm, and ResetForm functions after the ForAll function
    • It doesn't matter, and shouldn't impact what you're trying to do with the Patch(es)
    • Just wanted to point out that this is happening AFTER the ForAll function, in case you were intending/trying to do it for each loop of the ForAll

 

I recommend that you disambiguate the columns in your collections, to ease writing functions against them. For example, when you collect into Collection1, use something like 'appDowningId' instead. Then, when you're writing your Patch function in the ForAll, it will be much clearer when you're referencing that column or the destination's column.

Speaking of which, is the column in the SharePoint list actually downingid - why aren't you referencing the display name like the 'Trade Show Title' column?

 

Thanks @mperez84 ,

So downingid is a text field in Collection1 and you are patching this together with a static value from your screen as new records to a data source with a ForAll looping through the collection and it does not Patch a valid value.

The first thing I would suggest you try is as suggested by @GarethPrisk and rename the field in the collection to something else.

We can continue from there between us if that does not solve the issue.

 

 

v-yutliu-msft
Community Support
Community Support

Hi @mperez84 ,

Do you mean that the downingid field hasn't been updated successfully?

If so, I notice that you have the same field name in the collection and the list, which may lead some problems.

I suggest you use [@] to avoid ambiguity.

Try this formula:

ForAll(Collection1,Patch('Asset Request',Defaults('Asset Request'),{'Trade Show Title':DataCardValue1.Text,downingid:Collection1[@downingid]}))

 

 

Best regards, 

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

@WarrenBelz

 

I've changed the reference name from downingid to appdowningid, that didn't fix it.  I found when I removed from the onselect button formula the clear(collection1) the issue goes away.  But then obvious happens, when I select new form the previous selected data is there. 

 

Is there another way to clear the collection after submit? 

When you say 'submit', are you referring to?

  1. Patching of 'Asset Request' record(s) from Collection1
  2. The SubmitForm action for SharePointForm1

The ForAll function will loop through and create/update a record per row in Collection1 via the Patch function.

The SubmitForm function will causes that form to submit to the database. You can hook into it's OnSuccess action to perform another action, such as clearing Collection1.

 

What is SharePointForm1 connected to? What are you submitting via that?

Can you review/confirm Collection1 prior to the ForAll patch, to ensure all columns have data?

Hey @GarethPrisk 

 

Yes sorry ''submit'' is just the reference name to my button. 

 

The Sharepointform1 is connected a sharepoint list named  "Asset Request". This is where the collection and trade show title text field is being written back too. 

 

I've confirmed all the data during collection is there prior to the patch. 

 

removing the clear(collection1) from the ForAll/patch function causes all the columns to write appropriately. 

 

I'm not sure where else to try the clear collection function at. Ideally I would like this to be a single onselect button function. 

 

 

 

 

Okay, to clarify something real quickly:

  • The Form SharePointForm1 is connected to 'Asset Request'
    • This means, that when you invoke SubmitForm() against SharePointForm1, it will try to create/update a record in the 'Asset Request' list
  • The Patch function against Collection1
    • Is looping through the records in Collection1, and executing Function(s) against each row
    • The Patch function will create/update (create in your example, with Defaults() used) an 'Asset Request' record for each loop (record within Collection1)

The way your formula was written in the original screenshot indicates:

  • An 'Asset Request' record would be created for each row in Collection1
  • An 'Asset Request' record would be updated/created when you SubmitForm()

 

How are you collecting into Collection1?

Should you be creating a list of records, and then creating/updating another/an existing record as well?

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (64,460)