2

I have created blank canvas app and I want to create product details like product name, price, category,quantity, color, etc..., by using set function with OnStart property. Please, suggest any information about this.

I want to create global variable with Onstart property in blank canvas app.

Ganesh M
  • 21
  • 1
  • Suggest any solution... – Ganesh M Aug 10 '23 at 07:37
  • Any update here? Please [Upvote(^)](https://meta.stackexchange.com/questions/173399/how-can-i-upvote-answers-and-comments) and [accept as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) if it helped you in any way & it will help others with similar question in future to find the correct answer easily. – Ganesh Sanap Aug 21 '23 at 12:11

1 Answers1

2

If you have fixed set of products, you can write function like below in OnStart property of App object in your app:

Set (
    gvProducts,
    Table(
        {
            ProductName: "Product 1", 
            Price: 100,
            Category: "Category 1",
            Quantity: 5,
            Color: "Red"
        },
        {
            ProductName: "Product 2", 
            Price: 200,
            Category: "Category 2",
            Quantity: 10,
            Color: "Green"
        }
    )
)

It creates table of multiple records with same properties. You can adjust the data type of each property and add multiple records/objects as per your requirements.

enter image description here

Ganesh Sanap
  • 1,386
  • 1
  • 8
  • 18
  • alternatively you can use the same logic in the OnVisible property of the screen you set in the App.StartScreen property. Here's some detailed opinion why this is preferable: https://powerapps.microsoft.com/en-us/blog/app-startscreen-a-new-declarative-alternative-to-navigate-in-app-onstart/ – mmikesy90 Aug 11 '23 at 07:22
  • You can also use collections instead of global variable for storing multiple records/array. – Diksha Poddar Aug 11 '23 at 11:39