cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Running a loop in powerapps based on user input and save each record in db

Hi guys,

I am new to PowerApps and am struggling with a looping problem. I have a slider n user will select value on slider . According to selected value the  loop should be run and everytime record should be store in db – excel table. Data stored should be app name , id and vmname.

 Currently id has property that it will autoincrement with default property set to If(EditForm1.Mode = FormMode.New,Last(Table1).Id + 0001,Parent.Default)

And vmname has concatenate function Concatenate("test-",Text(DataCardValue5),Text(Label1))

 so I am looking to implement a case if user selects value 2 on slider  then following data should be saved to excel table

  1. App name   Id     vm name
  2. App1         0001  test-App10001
  3. App2         0002   test-App20002

 

Any assistance is greatly appreciated. And if you need any further information, I will happily provide.

 

Thanks

 

5 REPLIES 5
Dual Super User III
Dual Super User III

Hi @AzureLearner 

 

Can you please confirm the need of Edit Form here in this case? If you are dealing with individual controls, you can either create a button to create rows or can do it directly when the slider value is changed.
 
Expression that can be used:
 
ForAll(FirstN([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],Slider1.Value),Patch(Table1,Defaults(Table1),{AppName:Concatenate(TextInput1.Text,Text(Value)),Id:Text(Value(Last(Table1).Id)+1,"[$-en-US]0000"),'VM Name':Concatenate("test-",TextInput1.Text,Text(Value),Text(Value(Last(Table1).Id)+1,"[$-en-US]0000"))}))
 
Here, Slider1 is the name of Slider control and Table is the name of name of Excel table.MicrosoftTeams-image (18).png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Yes, I am having a form structure. This is part of my edit screen. PFA .

Hi @AzureLearner 

 

Looking at the screenshots, I am not clear on the fact why do you want to apply a loop on the Edit Form. Edit Form deals with a single item in the data source. This cannot be achieved with an edit form. Instead you can create independent controls and use Patch to create the records in data source. For that, you use the formula I provided in my previous comment. 
 
Please share more information about the logical implementations so that we can help you better.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

@yashag2255 

 

I have three screens.Basic motto of application is to create unique names by appending app name + number-id.
1)On edit screen I have provided radio button of one n multiple.

If user selects one then user can add app name , id auto populated (autoincremented by 1) and vmname is generated with concatenation.

2)I am looking to create multiple vmnames similarly.
if user selects mutiple - radio button , slider will be visible.
if user selects value 2 on slider,
at first I will be entering app name: testapp1 Id: last +1 :e.g 6 ->vmname testapp10006

this should be saved in excel table.

Next I will be entering  app name: myapp1 Id: last +1 :e.g 7 ->vmname myapp10007

This also should be saved. 

 

Let me know if any more info I need to share.Thank you!

Hey @AzureLearner 

 

When you are selecting multiple radio button, do you wish to enter the values everytime or this will get autogenerated when the user input is added for the first item? Also, If you are looking for entering all the values, will this be done on a single click or the user is supposed to click everytime the form is entered with some value?

If you wish to create VM name based on App Name entered and the ID, you can use the concatenation formula as:
 
Concatenate(DataCardValue1.Text,Text(Value(DataCardValue2.Text),"0000"))
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (2,336)