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

Can't insert icon into form - it goes into the screen object only.

I need to insert an icon into an editable form to reset my form's controls.  (It is often very frustrating attempting to insert an object into a gallery or a form.  Powerapps seems to want to insert it into the parent object instead.)

When the icon is inserted, it is "under" the screen object in tree view, not the form object, and PowerApps throws an error when attempting to use the Reset method:  "The reset function can only be used with a resettable control. Controls within a Form or Gallery control can only be reset from within the same form or gallery template."  I tried selecting the form object in the tree view before inserting my icon, but that just doesn't work.  I tried it about a dozen times.  Sheesh!

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Can't insert icon into form - it goes into the screen object only.

Hi @jhn1,

 

By saying FormMode.Add, do you mean you would like the form to keep stayed in the New Record (FormMode.New) state?

If that is the case, then please switch to the NewForm() function, and it doesn't matter whether the control is within or outside the form control, using the NewForm() would always work to set the form control (together with the controls added in the form) to the New form state.

 

Besides, if you prefer to set the controls one by one, then please consider take use of the Variable option.

With the OnSelect property of the icon, add:

UpdateContext({ResetVar1:true});UpdateContext({ResetVar1:false})

Then under the ReSet property of each control that you would like to reset, enter:

ResetVar1

which should be able to achieve what you want.

 

For the Downside, that depends on the basic requirements, mostly using the Form control with the submitForm() function, the form itself would update its .LastSubmit property automatically, which also contains the Server side field.

For Patch(), if the Server side field needed, we need to collect the record returned by the Patch().

And as here you are using Excel, so this should be not under the concerns.

 

By the way, for using patch to create new record, see blog post from @Meneghino to gain a better performance:

Replace the Defaults() function to improve Performance

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
10 REPLIES 10
Super User
Super User

Re: Can't insert icon into form - it goes into the screen object only.

You have two choices for adding a icon to a form. You can do it with in an existing data card or in a custom data card. Id you are adding it to an existing data card then you need to make sure that the data card is unlocked otherwise the icon will not be added to the form but instead to the screen even though you had the data card selected when you inserted it.

 

If you want to create a custom card then you need to select the form and in the property pane select the data source name. This will open the data source/layout/fields pane. Click on the ellipse ("...") that is to the right of "Fields" and click "Add a custom card". Once you have the custom card created just select the card and add the icon. You can then move the custom card to any position on the form.

jhn1
Level: Powered On

Re: Can't insert icon into form - it goes into the screen object only.

Hi, Jeff,

 

Thanks for your kind reply. 

I tried your solution by creating a custom card and inserting an eraser icon into it.  You said "you can then move the custom card to any position on the form."  However, I want the icon to be on my "rectQuickActionBar" and can't seem to move it there as a part of a custom card.  The other icons on the "rectQuickActionBar" are under the form object in tree view, not part of custom cards, and I want to emulate that.  Can you advise me?

 

Thanks so much! 

Super User
Super User

Re: Can't insert icon into form - it goes into the screen object only.

Can you provide a screenshot of your tree view? My guess is that the "rectQuickActionBar" is not a child control of the form control but is layered below the form.

jhn1
Level: Powered On

Re: Can't insert icon into form - it goes into the screen object only.

Here is the screen shot you asked about; I hope it helps.  Thanks!

CaptureTreeView.JPGTree View

Super User
Super User

Re: Can't insert icon into form - it goes into the screen object only.

The "recQuickActionbar" is not part of the form control. If you click on the twistie next to "frmAddProject" you will see all the fields/controls associated with the form collapse. If you are trying to use a reset control which requires the control to be with in the form or gallery then  you can't add it to "recQuickActionbar" because it is out side form. The order of the objects in the tree view represent the layer order of the objects and the twisties show which objects have children objects.

Community Support Team
Community Support Team

Re: Can't insert icon into form - it goes into the screen object only.

Hi @jhn1,

 

Which control you are trying to ReSet here?

As @Jeff_Thorpe mentioned, the DataCard within the form control need to be unLock first before we can insert new objects into it.

If you would like to gain a full understanding of How the form and DataCard works, then please review:

Understand data forms in Microsoft PowerApps

Understand data Cards

 

Further, for the reset, could you please explain a bit for that?

Basically, the Form could be reset by ReSetForm() function, and the control added within it could be ReSet by its ReSet property (If it has the ReSet Property).

There is no need to add a button within the corresponding DataCard to reset it, we could achieve it by setting Variables.

You may follow the steps below to give it a try:

1. Add a button, with its OnSelect property, enter the following:

UpdateContext({Reset1:true});UpdateContext({Reset1:false})

2. Under the ReSet property of the control (mostly should be DataCardValue Number) you would like to work with, enter the following:

Reset1

Another workaorund should be using the ReSet() function with the corresponding control name, and this requires the Button to be added within the DataCard.

Steps should be:

1. Select the Special DataCard from the tree view, then under the Advanced pane(Right side), click UnLock to change properties,

2. InSert a New Button, then under its OnSelect property, enter the following:

ReSet(DataCardValueXX)

 Doing it in this way should be able to have the ReSet work.

 

Let me know if you have any further questions.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jhn1
Level: Powered On

Re: Can't insert icon into form - it goes into the screen object only.

Thanks, I appreciate your time here.

 

I am trying to reset all the controls on the form after a submission in which I use patch (it's an excel data source and patch seems to work best for that).  I noticed that my data stayed around after the submission, so I wanted the user to be able clear the form with an icon on the RecQuickActionBar. 

 

I don't want to use the ResetForm method to reset the controls because this will change my form's Mode to FormMode.Edit after it runs; I want my form to stay in FormMode.Add.  Additionally, I don't think I could use it because my inserted icon is outside the form; it's under the screen object. 

 

My work around was to add reset functions for each control as a set of functions that run after the Patch function.  My form has only 5 or 6 controls so it wasn't hard to do and this seems to prevent data from hanging around.  Can you see any downside to this approach?

 

Thanks again for your time and interest.  These forums really help us newbies!!

 

-jhn1

Community Support Team
Community Support Team

Re: Can't insert icon into form - it goes into the screen object only.

Hi @jhn1,

 

By saying FormMode.Add, do you mean you would like the form to keep stayed in the New Record (FormMode.New) state?

If that is the case, then please switch to the NewForm() function, and it doesn't matter whether the control is within or outside the form control, using the NewForm() would always work to set the form control (together with the controls added in the form) to the New form state.

 

Besides, if you prefer to set the controls one by one, then please consider take use of the Variable option.

With the OnSelect property of the icon, add:

UpdateContext({ResetVar1:true});UpdateContext({ResetVar1:false})

Then under the ReSet property of each control that you would like to reset, enter:

ResetVar1

which should be able to achieve what you want.

 

For the Downside, that depends on the basic requirements, mostly using the Form control with the submitForm() function, the form itself would update its .LastSubmit property automatically, which also contains the Server side field.

For Patch(), if the Server side field needed, we need to collect the record returned by the Patch().

And as here you are using Excel, so this should be not under the concerns.

 

By the way, for using patch to create new record, see blog post from @Meneghino to gain a better performance:

Replace the Defaults() function to improve Performance

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Support Team
Community Support Team

Re: Can't insert icon into form - it goes into the screen object only.

Hi @jhn1,

 

Do you need any further help on this topic?

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.