cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SauravGayawar
Level: Powered On

API DataSource does not refresh the data

I have created a simple API application to add, remove and list employees, i am using it in PowerApps, i can add/remove employee through the PowerApp but added/removed employee does not reflect in the application untill i restart the application or rebind the datasource.

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff carlosag
Power Apps Staff

Re: API DataSource does not refresh the data

Just to make sure, if I understand correctly you have built a custom api and exposed functions to "Listitems, Deleteitems, AddItem, etc).
Then I imagine you bound say ListItems to a gallery to display the items. And when you add a record, you don't see it in the list.

At this point we do not 'poll' the API since we do not know what it could be doing (side-effects), so you need to "control the refresh of data when using Custom APIs".

Here is the way you could do that:
1) You would assign the Items to a "Context variable" using UpdateContext
2) Bind the gallery instead to that variable
3) After making a change you can re-set the context variable to refresh the Gallery.

 

Basically add to the OnVisible of the Screen something like:
UpdateContext( { MyItems: YourCustomAPI.GetItems() } )

 

Then to the gallery Items property bind to : MyItems

 

And then after the add, call the same UpdateContext logic separating by a ";" like:

YourCustomAPI.AddItem("something"); UpdateContext( { MyItems: YourCustomAPI.GetItems() } )

View solution in original post

1 REPLY 1
Power Apps Staff carlosag
Power Apps Staff

Re: API DataSource does not refresh the data

Just to make sure, if I understand correctly you have built a custom api and exposed functions to "Listitems, Deleteitems, AddItem, etc).
Then I imagine you bound say ListItems to a gallery to display the items. And when you add a record, you don't see it in the list.

At this point we do not 'poll' the API since we do not know what it could be doing (side-effects), so you need to "control the refresh of data when using Custom APIs".

Here is the way you could do that:
1) You would assign the Items to a "Context variable" using UpdateContext
2) Bind the gallery instead to that variable
3) After making a change you can re-set the context variable to refresh the Gallery.

 

Basically add to the OnVisible of the Screen something like:
UpdateContext( { MyItems: YourCustomAPI.GetItems() } )

 

Then to the gallery Items property bind to : MyItems

 

And then after the add, call the same UpdateContext logic separating by a ";" like:

YourCustomAPI.AddItem("something"); UpdateContext( { MyItems: YourCustomAPI.GetItems() } )

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,016)