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

COLLECT: Writing extra records

I'm not sure how, but each write to my Data Source (Sharepoint) is creating a blank record along with the actual records. Maybe you can see where I'm messing up here: 
Use Case:

  • Offline-capable app (my first!) for simple equipment measurements
  • Offline capabilities are not implemented yet.
  • OnStart, a hardcoded EquipmentCollection is created of all possible Equipment/Widget combinations (only 😎
  • Using a Form control for Error Handling and other things (don't ask 🙂 ), but NOT using SubmitForm()
  • Some of the choices require multiple iterations through the Form (tricky)
    • Example of tricky-ness:
      • User selects "Equipment 12" from Equipment Name dropdown
      • The Widget Name dropdown now shows two separate Widgets to inspect for that particular piece of Equipment.
      • Both Widgets require the exact SAME measurements to be captured in the Form

Scenarios

  • If Equipment has only 1 Widget (requires 1x Form)
    • User clicks Submit
    • Collection is created of all Form fields (RecordCollection)
    • If CountRows of EquipmentCollection = CountRows of ReadingCollection, 
// Show the user that the Widget measurement is "Completed"

Update(EquipmentCollection,
        First(
            Filter(EquipmentCollection, 
                equip = EquipmentName.Selected.Value
                And widget = WidgetName.Selected.Value
            )
        ),{equip: EquipmentName.Selected.Value, widget: WidgetName.Selected.Value & "-COMPLETED"}
    );

// Write the RecordCollection back to the Sharepoint List as a new record

    Collect(SharepointListName,
        Defaults(SharepointListName),
            RecordCollection
  • If Equipment has 2 Widgets (requires 2x Form)
    • User clicks Submit
    • Collection is created of all Form fields (RecordCollection)
    • If CountRows of EquipmentCollection <> CountRows of ReadingCollection,
      • Notify() User that Widget2 needs to be measured
      • Reset() Form fields
      • Widget1 shows as "Completed" in the dropdown
    • User completes measurement of Widget2
    • User clicks Submit
    • Same code as above runs
// Show the user that the Widget measurement is "Completed"

Update(EquipmentCollection,
        First(
            Filter(EquipmentCollection, 
                equip = EquipmentName.Selected.Value
                And widget = WidgetName.Selected.Value
            )
        ),{equip: EquipmentName.Selected.Value, widget: WidgetName.Selected.Value & "-COMPLETED"}
    );

// Write the RecordCollection back to the Sharepoint List as a new record

    Collect(SharepointListName,
        Defaults(SharepointListName),
            RecordCollection

Ha! Feel a little funny writing this all up with no screenshots. Hopefully its clear. 

The results is the correct data being written to the Sharepoint List WITH a blank record as well. There is a blank row between every record (whether a single Widget record or 2 Widget record).

 

 

7 REPLIES 7
timl
Super User III
Super User III

Hi @ericonline

To diagnose this a bit further, could you somehow view RecordCollection before you Collect it, just to confirm that it contains the data that you expect (without any blank rows)?
Perhaps you could do this by viewing File > Collections, or by storing it in another variable that you can inspect afterwards.

ericonline
Community Champion
Community Champion

Hi there @timl. Thank you for the response. The collections do not show blank records when working in the IDE.

I think I figured it out... It seems to be happening on mobile only. Looks like it might stem from the SaveData() LoadData() logic. I think the app is loading the saved file (collection) with a blank record in it, then adding this to the Patch.

I'll investigate a bit more and let you know what I find.

Take care!

 

 

Hi @ericonline

I'm glad you're making progress on this. If you want a quick fix to this, I suppose you could Filter the RecordCollection in your call to Collect to remove any blank rows.

I'd be interested to see what you find following your investigations.

Have a nice weekend and take care too Eric!

ericonline
Community Champion
Community Champion

Baffler! I updated the logic as follows thinking it would clear the mystery blank record in "offlineCollection":

  • If Connected = true
    • Patch data source with values
    • Clear(offlineCollection)
    • SaveData(offlineCollection,"offlineCollection")

I'm going to try your Filter() trick next. Thanks @timl!

Hi @ericonline

That is very strange, especially how you get black rows between each record that you collect!

Hopefully, the Filter trick will fix this problem but it would be interesting to understand the cause.

Anonymous
Not applicable

Thanks for your help with this thread @timl

 

@ericonline - have you made any progress with this issue?

 

@Anonymous

Hi @Anonymous, not yet. Too many irons in the fire! This one might have to wait till 2019 🙂 Vacay approacheth!

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 (19,203)