cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Load the data card on Start

All,

I am an app that needs to to load sharepoint data on start. once data is loaded, I have a checkbox that filters the data.

The issue is that data does not load unless I select or unselect the checkbox. I have tried to use onStart but it seems it does not work.

To filter the data with the checkbox, I have defined two valriables and wrote the following filter.

UpdateContext ({filterBy:1})

UpdateContext ({filterBy:2})

Switch(filterBy,1, SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && IsBlank(ITSM_Ticket)),"ITSM_Ticket", Descending),2, SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && !IsBlank(ITSM_Ticket)),"ParentID", Descending))

How do I get the data to load when app is starting?  Any idea?

 

Thanks,

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Thank you all who answered. Greatly appreciated. IT seems to work now.

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@Anonymous you have supplied three different statements.  Can you describe where you have these statements (i.e. what actions, properties, etc)?

 

Are you stating that the UpdateContext statements are in your CheckBox actions?

Are you stating that the Switch statement is your Items property on your 'whatever'?

If so, then what have you put in your OnStart?

 

If this is the case, then you will need to put your default state UpdateContext statement in OnStart. HOWEVER - you cannot put an UpdateContext in the OnStart because it does not have a screen scope, it has an app scope.

 

Please clarify what you are doing/seeing.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Anonymous
Not applicable

Hi Randy,

Thanks for responding.  

Are you stating that the UpdateContext statements are in your CheckBox actions? " Yes.

" Are you stating that the Switch statement is your Items property of the data card?" Yes

 

I am new to PowerApps, I tried to put the Filter/switch in onStart property. since it did not work, I took it out and put it back on item property of datacard. 

 

So basically, what I am trying to do is when the app starts, I need to have the data loaded on the datacard.

once it is loaded, if a user select the checkbox, then the list that is loaded needs to be filtered.

 

Thanks in advance,

 

No problem.  It's easy to get terms confused when new to the PowerApps world.

So a couple points of clarification:

1) You mention DataCards and Lists - these two are two different things. 

Lists - So, I am going to assume you have a Gallery or other type of list control.  If this is the case, then you will be setting the Items property of the control to your Filter statement.  In fact you might consider changing that to simplify - more on that later.

DataCard- So I am going to assume you have an EditForm control in your app.  If so, then you will set the DataSource to your ChkList_TaskList list and your Item to whateverYourListIs.Selected

 

2) Where is the CheckBox control?  Is it part of the actual data or is it a separate control you intend to use to simply "filter" data?

 

2)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
v-xida-msft
Community Support
Community Support

Hi @Anonymous,

Do you want to load the data when your app starts without checking or uncheck the Checkbox control within your app?
I have made a test on my side, please take a try with the following workaround:

Set the Items property of the data card to following:

Switch(
filterBy,
1,
SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && IsBlank(ITSM_Ticket)),"ITSM_Ticket", Descending),
2,
SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && !IsBlank(ITSM_Ticket)),"ParentID", Descending),
ChkList_TaskList /* <-- Type your data source here. When your app starts, all records of your ChklIst_TaskList would load */
)

Or

Switch(
       filterBy,
       1, 
       SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && IsBlank(ITSM_Ticket)),"ITSM_Ticket", Descending),
       2, 
       SortByColumns(Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate) && !IsBlank(ITSM_Ticket)),"ParentID", Descending),
       Filter(ChkList_TaskList, Text(Created, DateTimeFormat.ShortDate) <> Text(Today(), DateTimeFormat.ShortDate))  /* <-- Filter your ChkList_TaskList data source by current date */
)

Set the OnCheck property of the Check Box to following:

UpdateContext ({filterBy:1})

Set the OnUnCheck property of the Check Box to following:

UpdateContext ({filterBy:2})

 

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.
Anonymous
Not applicable

Thank you all who answered. Greatly appreciated. IT seems to work now.

View solution in original post

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

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