Skip to main content

Notifications

Community site session details
Power Apps - Building Power Apps
Answered

Creating a Form like structure with Collections as a Data source

Like (0) ShareShare
ReportReport
Posted on 11 Nov 2021 19:03:47 by 20

Hello,
I am working on a stuff which requires me to generate a form like structure by using Collections as a data source. Tried using Forms with Collections, got to know that it's not a valid data source for Forms.
I am attaching the JSON below for reference.

 

I want to display the 'Key' (as label) along with the value (Text Input) in Form/Form like structure, It would be great if I get these fields dynamically populated once I click a button, I don't want to hard-code the fields and Text-Input.

Thank you!

  • Rohit_RC Profile Picture
    20 on 17 Nov 2021 at 08:05:52
    Re: Creating a Form like structure with Collections as a Data source

    hi @PTBBSolutions , hope you're doing good.

    I have a use case scenario wherein we have a JSON file stored in Dataverse. How can we display the content from the JSON file (stored in Dataverse) in rich text editor control in canvas app.
    I am using a Attachment control available in Form, through which I am able to upload JSON files into the Dataverse, I want the JSON file's content stored in Dataverse to be displayed.

    I am trying to use a Flow, but unable to figure out.

    Thank you.

  • Rohit_RC Profile Picture
    20 on 12 Nov 2021 at 08:42:35
    Re: Creating a Form like structure with Collections as a Data source

    Hi @PTBBSolutions ,
    First(Collection_Name) will only return the first element
    I want all the elements in the form fields, and moreover ThisItem.passwordLabel will give the value associated with "passwordLabel" key.

    The following is my collection : 

    Collect(
    CustomCollection,
    {userLabel: "User ID"},
    {passwordLabel: "Password"},
    {forgotUserId: "Forgot user ID?"},
    {forgotPassword: "Forgot password?"},
    {keepMeIn: "Keep me signed in for 2 weeks"},
    {saveUserId: "Save user ID"},
    {signInButton: "Sign in"},
    {cancelSignInBtn: "Cancel"},
    {dontHaveId: "Don't have a user ID?"},
    {createUserNow: "Create one now"},
    {eRepairSignInWithPhoneNumber: "Sign in with phone number"}
    )

    based on the above collection, what I want is to display an edit form in the following way : 

    userLabel (as a label) : User ID (in a text Input, so that it can be edited)
    passwordLabel (as a label) : Password (in text Input, so that it can be edited)
    .
    .
    so on and so forth

    I don't know if this is possible with a form. If this is not a viable way to solve this problem, alternative solutions will be much appreciated .

    Thank you.



  • Verified answer
    PTBBSolutions Profile Picture
    691 on 12 Nov 2021 at 08:16:45
    Re: Creating a Form like structure with Collections as a Data source

    Hi @Rohit_RC ,

     

    I have a collection which is created from a button click the following way:

    Collect(MyCol,{userLabel: "User ID",passwordLabel:"Password"})

    I also have an edit form with the following attributes:

    1) DataSource: MyCol

    2) Item: First(MyCol)

     

    After that I manually add datacrds in the edit form:

    PTBBSolutions_0-1636704829851.png

    After you have created a datacard, add a control in it (label or text input or whatever you want).


    Set the Text property of your control (if it is a label) to /e.g/ ThisItem.passwordLabel.

     

    This way your form will be always dynamic based on your collection:

     

    PTBBSolutions_1-1636705017022.png

     

     

  • Rohit_RC Profile Picture
    20 on 12 Nov 2021 at 07:49:20
    Re: Creating a Form like structure with Collections as a Data source

    @PTBBSolutions  Thanks for replying
    If we use Data sources like Excel, Dataverse tables for Edit forms, the fields (labels and text inputs) are automatically populated, in the same manner, if my data source for Edit Form is a Collection, I want the fields(Labels and text inputs) to populate automatically.
    please suggest any alternatives accordingly

    At present, I have created labels and text inputs in a blank vertical gallery, Please find the pic attached to this answer
    I want the same to get populated in a Edit Form automatically based on my collection's key-value pairs.

  • PTBBSolutions Profile Picture
    691 on 12 Nov 2021 at 07:28:12
    Re: Creating a Form like structure with Collections as a Data source

    Hi @Rohit_RC ,

     

    What do you mean by "Collection is not a valid data source for Forms"? You can use a collection in your form, just change your Item property to First(YourCollectionName).

     

    BTW, are you sure this is the way you want you collection to be structured? I think that you need to have all data in 1 row and not on multiple.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,089 Most Valuable Professional

Leaderboard
Loading started
Loading started