cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Resolver I
Resolver I

Remove record from collection that is populated using a calendar

Hi, I have a calendar created:

TB05_0-1649688562309.png

The Onselect for the Continue button is:

Set(varBonusStartDate, DateValue(Text(_selectionStart, ShortDate)));
Set(varBonusEndDate, DateValue(Text(_selectionEnd, ShortDate)));
Collect(yourCollection,
ForAll(Sequence(DateDiff(varBonusStartDate, varBonusEndDate, Days)+1, 0),
{colDate: DateAdd(varBonusStartDate,Value, Days)}
)
);
Set(varBonusDateCount, CountRows(yourCollection));
UpdateContext({viewCalendar:false});

If I select Days 11 & 12, yourCollection will have those days added to the collection.  But, if I re-open the calendar and want to change the days selected to Days 10 & 11, in my collection I have 10, 11, 11, 12 days (4 days).  Instead of 10 and 11. How do I get 10 & 11 without clearing the collection all together?

TB05_1-1649688770282.png

TB05_2-1649688784574.png

I do have a button that will clear all:

UpdateContext({viewCalendar:false});
Clear(yourCollection);
Set(varBonusStartDate, Blank());
Set(varBonusEndDate, Blank());
Set(varBonusDateCount, Blank());

The code on the SELECT of the Day is:

If( Month(DateAdd(_firstDayInView,ThisItem.Value,Days))<>Month(_firstDayOfMonth),
0,

_selectedCount > 0
&& DateAdd(_firstDayInView,ThisItem.Value,Days) >= _selectionStart
&& DateAdd(_firstDayInView,ThisItem.Value,Days) <= _selectionEnd,
UpdateContext({_selectedCount: 0}),

_selectedCount = 1,
UpdateContext({_selectionStart: Min(_selectionStart, DateAdd(_firstDayInView,ThisItem.Value,Days)),
_selectionEnd: Max(_selectionStart, DateAdd(_firstDayInView,ThisItem.Value,Days)),
_selectedCount: 2}),

UpdateContext({_selectionStart: DateAdd(_firstDayInView,ThisItem.Value,Days),
_selectionEnd: DateAdd(_firstDayInView,ThisItem.Value,Days),
_selectedCount: 1}))

 

 

It seems to me that the issue is when I deselect the calendar day (no longer high-lighted) the _selectionStart and the _selectionEnd entry is still the last entry selected, they do not go back to blank.  Any thoughts on how to do that?  I guess it has to do with my count???  

0 REPLIES 0

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,822)