cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Greg-au
New Member

Clear form viewer when starting the app

Hi Everyone,

Teaching myself powerapps and want to create a simple add new user request. The app is connected to SharePoint Online List.

I have a home screen with a button to start the new user request and below it is a form viewer that I want to be not visible on start but when the request is submitted shows the latest list entry which should be the one the user just entered.

On the FormViewer Item field I have - Last(Sort('New Users',ID,Ascending)). This gives me the latest user created but it carries over to the next time the app is started.

 

Any advice would be appreciated.

 

FormViewerFormViewer

1 ACCEPTED SOLUTION

Accepted Solutions

@Greg-au 

You can use a context variable to either true or false as the result of a condition.   If you want it hidden by default, then in the OnVisible property of the  Screen containing the Viewform put

 

UpdateContext({visvar:false})

 

Then set the Visible property of the FormViewer to visvar. 
The SubmitForm icon should never have anything other than SubmitForm(FormX) as its OnSelect property.  The OnSuccess property of the form itself is be used to change the context variable.  This formula should be in the OnSuccess property of the form

 

UpdateContext({visvar:true})

 

That way, the form would not be shown unless the form was successfully submitted.  As soon as the data is successfully submitted, the View form would be unhidden.  If you had an Edit form on the same screen, then the Edit form Visible property would be set to !visvar.  That would toggle the View form and and Edit form so either one or the other was hidden when the other form was visible. 

Another trick is to create a toggle button that hides and unhides the forms.  The OnSelect property of a button or Icon with the formula

UpdateContext({visvar:!visvar})

would do that.  

  

View solution in original post

3 REPLIES 3
Drrickryp
Super User II
Super User II

@Greg-au 

To avoid delegation problems you want First(Sort('New Users',ID,Descending)).  Your formula will max out at 2000 names (if you have increased File>Settings>Advanced Settings>Data row limit to 2000 from the default of 500.  

@Drrickryp , Thanks for responding and will look at that change.

Any advice on how to have the formviewer not visible until a user has submitted a request?

By default I have FormViewer1 set to visible=false

I was looking at the submit form icon and trying to figure out how to then set FormViewer1 to visible to show/confirm what they just requested.

I have tried SubmitForm(EditForm1); FormViewer1.Visible=true

Any thoughts

@Greg-au 

You can use a context variable to either true or false as the result of a condition.   If you want it hidden by default, then in the OnVisible property of the  Screen containing the Viewform put

 

UpdateContext({visvar:false})

 

Then set the Visible property of the FormViewer to visvar. 
The SubmitForm icon should never have anything other than SubmitForm(FormX) as its OnSelect property.  The OnSuccess property of the form itself is be used to change the context variable.  This formula should be in the OnSuccess property of the form

 

UpdateContext({visvar:true})

 

That way, the form would not be shown unless the form was successfully submitted.  As soon as the data is successfully submitted, the View form would be unhidden.  If you had an Edit form on the same screen, then the Edit form Visible property would be set to !visvar.  That would toggle the View form and and Edit form so either one or the other was hidden when the other form was visible. 

Another trick is to create a toggle button that hides and unhides the forms.  The OnSelect property of a button or Icon with the formula

UpdateContext({visvar:!visvar})

would do that.  

  

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

Top Solution Authors
Top Kudoed Authors
Users online (75,927)