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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dynamically create new...
Power Apps
Unanswered

Dynamically create new controls in Gallary

(0) ShareShare
ReportReport
Posted on by

Hi guys,

 

I'm new to Powerapps and don't understand how to patch different controls with a button.

I have a sharepoint list with all my data and use this to create a questionare using a Gallary and hiding controls based on their type (i.e Text Input, Drop Down and Check Boxes). How would I patch these different results captured in these different controls to my sharepoint list? Do I need to create different buttons and then hide them based on ontrol type or can all be done with one button?

 

See attached picture.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,030 Most Valuable Professional on at

    Hi @Anonymous ,

    If you are referring to the syntax required (replace with your names

    • Checkboxes are YourControlName.Value
    • Text boxes are YourControlName.Text
    • Dropdown/ComboBoxes are YourControlName.xxxx  (see below)
      • Value for Choice and Lookup fields
      • Result for Distinct filters
      • FieldName (actual field name) if based otherwise on a list field

    Happy to elaborate further

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    on at

    This is the patch function that I'm using for my "Save" button:

     

    Patch('KPI Write To',Defaults('KPI Write To'),{PPMUniqueID: ThisItem.PMMUniqueId, Answer:AnswerTextInputControl.Text, Comment:CommentTextInputControl.Text, Timestamp: Now()})

     

    But this would only apply to the 'Text Input' controls that I have and not to the check boxes or dropdowns.

    So my question is: Would I have to create multiple buttons to cater for different controls or can tis be done with one button?

     

    Please let me know if you need more information.

  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @Anonymous ,

     

    You can apply condition to check if the text input box, dropdown or check box is visible, and then patch corresponding control value.

    Except that, you also can check each items type to determine which control value to be patched.

    For example, I assume there is a column named type in the backend data source.

    Patch('KPI Write To',Defaults('KPI Write To'),{PPMUniqueID: ThisItem.PMMUniqueId,

    Answer:

    If(

    ThisItem.Type= "TextInput", AnswerTextInputControl.Text,

    ThisItem.Type= "Dropdown", DropdownName.Selected.Value

    ThisItem.Type= "Checkbox", If(Checkbox1.value,"Yes", Checkbox2,Value,"No")

    ),

    Comment: CommentTextInputControl.Text, Timestamp: Now()})

     

    Hope this helps.

    Sik

  • Community Power Platform Member Profile Picture
    on at

    @v-siky-msft I still get an error when I attempt this.

    My Function:

    Patch('KPI Write To'
    ,Defaults('KPI Write To'),
    {PPMUniqueID: ThisItem.PMMUniqueId,
    Answer:
    If(ThisItem.QuestionType= "Text", AnswerTextInputControl.Text ,

    ThisItem.QuestionType= "Dropdown", DropDownControl.Selected.Value,

    ThisItem.QuestionType = "Choice", If(yesCheckbox.Value,"Yes", NoCheckbox.Value,"No")
    ),

    Comment: CommentTextInputControl.Text, Timestamp: Now()})

     

    Error: The function 'If' has some invalid arguments

     

    I also attached my Sharepoint list that I use as a source and the one I write to.

    Please see how I get my dropdown values. I use a split function with | as a delimiter.

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    @v-siky-msft Thank you. I only needed to change the DropDownControl.Selected.Value to DropDownControl.SelectedText.Value because of the way my dropdown values are sourced. 

  • DevendraSingh Profile Picture
    144 on at

    Hi,

    Refer to the one my post to generate control in the gallery dynamically.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/If-select-amount-quot-x-quot-option-quot-x-quot-text-boxes-will/m-p/570894#M177445

    Please click Accept as Solution, if this solution solved your issue. If this post was useful, please consider giving it Thumbs Up.


    Thanks & Regards,

    Devendra Singh

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard