web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / code for creating an '...
Power Apps
Unanswered

code for creating an 'add' or 'remove' button in a powerapps form

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, has anyone created code for adding or removing fields in a powerapps form? for example, after adding a persons name, address, phone I need to create an 'add' / 'remove' button to add further persons details. This is from a user's perspective by the way, like filling out a guest form.

 

Thanks in advance

Categories:
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Anthjanz_42,

    Could you please share a bit more about the scenario:

    1. Do you want the Button to add/remove the current field value?
    2. More details for this add/remove Button.

    More details would be helpful to figure it out.

    Best Regards,

    Qi

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Qi, I have a powerapps form where i need a 'add' and 'remove' buttons for the user of the form. for example there are 3 fields (Name, mobile, email) and the user of the form needs to be able to click on a 'add' button to add a new field (under existing) so a 2nd persons details (Name, mobile, email) can be inputted. some forms may need up to 10 of these fields so hence need for 'add' and not just a hide/show fields option. And obviously 'remove' in case they added too many fields. 

    I hope this helped clarify what i need.

    Thanks in advance

    Regards

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Anthjanz_42,

    Do you want to add/remove a control dynamically based on the users within a form?

    Could you please share a bit more about the added field, is it a totally new one that differs from the existing ones, like Address or Region?

    Firstly, if you want to click a button to add/remove control in a form, I am afraid that there is no way to achieve this in PowerApps.

    If you would like this feature to be added to PowerApps, please submit an idea to PowerApps Ideas Forum :
    https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

    According to your idea, the newly added fields do not exist in your data source, so how do you save the data of these new fields? 

    Secondly, if you want to save the value of the newly added field that does not exist in the data source, the same can't be said for this one.

    Based on my understanding, there is no way to achieve your needs directly. If there is anything wrong with my understanding, please feel free to contact me.

    Best Regards,

    Qi

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Qi, sorry i have not answered back I was unable to for some reason. What I'm trying to do is the traditional e.g. add a guest to a web form. So like a whole row, 3 fields 'Name, Address, Mobile'. 
    I am split between trying to use a incremental count so hidden fields are revealed (haven't got the code figured out yet) OR using the 'Collect' function. The Collect function thought wants a Gallery inserted which visually is not great for our government forms. Also having trouble getting the data saved to SP.

    Any help would be most appreciated.

    Cheers

  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    Hi @Anonymous  you may want to use a gallery for this depending on the complexity of your form.  as mentioned, form is best to capture the inputs and regenerate a new form for the second set of input.

     

    Have a look at this to give you an idea.

    Here is a gallery, the collection adds some columns which are blank and a counter

    Collect(_govForm,{Name:Blank(), Surname: Blank(), Mobile: Blank(), Email: Blank(), ID: __ID});
    UpdateContext({__ID:__ID + 1})

     

    The collection function will add a single entry and it will be visible as below. you will notice two icons, + and X

    rubin_boer_1-1613371047823.png

    the + icon have the same code to it as the onvisible code and add a new entry to the gallery which will show that row in the gallery:

    Collect(_govForm,{Name:Blank(), Surname: Blank(), Mobile: Blank(), Email: Blank(), ID: __ID});
    UpdateContext({__ID:__ID + 1}).

    by clicking twice the gallery gets two more rows

    rubin_boer_0-1613371030922.png

     

    the x will delete the selected row

    Remove(_govForm,LookUp(_govForm,ID=ThisItem.ID))

     

    hope this helps you.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard