cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramole
Super User
Super User

Auto Add

Hello Everyone,

 

I need help on this please i am trying to archive this, i have a form and gallery repeating and i would when user enters Number Package field example 2 on form then the bottom repeating gallery to add 3 blank lines, whats the logic or formula to use please.

here is a screen shot 

Thanks 

 

galleryaddauto.png

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Ramole ,

 

Yes, try this. If the text box is not blank, save the value into a variable and create blank records, when the text box is cleared, remove the Last N records based on the variable.

If(IsBlank(DataCardValue60_2.Text),
Remove(NewShipCollection, LastN(NewShipCollection, VarNum)), 
Set(VarNum,DataCardValue60_2.Text);ForAll(
FirstN(ColNum,Value(VarNum)),
Collect( NewShipCollection,
{CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
Clevel: "",
Ctc: "",
Cdescription: ""
})))

Hope this helps.

Sik

View solution in original post

11 REPLIES 11
WarrenBelz
Super User
Super User

Hi @Ramole ,

Assuming you will have a small number of these, the code for up to three is below - you could extent this as far as you wish - the code will stop when it reaches the number it needs to be greater than.

If(
   Value(
      YourNumberFieldName.Text
   )>0,
   Patch(
      YourListName,
      Defaults(YourListName)
   )
);
If(
   Value(
      YourNumberFieldName.Text
   )>1,
   Patch(
      YourListName,
      Defaults(YourListName)
   )
);
If(
   Value(
      YourNumberFieldName.Text
   )>2,
   Patch(
      YourListName,
      Defaults(YourListName)
   )
)

 

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.

 

Hi @WarrenBelz 

Where should i use that code and all i was looking is when input the text box value in number i would my collection gallery to add create the lines for me, here is my collection formula that adds row or lines 

 

Collect(
NewShipCollection,
{
CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
Clevel: "",
Ctc: "",
Cdescription: ""
}
)

 

Thanks 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

Hi @Ramole ,'

I simply answered your question for code to produce new lines. You could trigger it from a button or from the OnChange of the number field - that is up to your functional requirements.

Your collection is another question.

 

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.

Hi @WarrenBelz 

 

This is repeating gallery and to add another line or row is doing collection as is not patching is only just adding new rows then i patch ForAll thats fine but on OnChange the field i would to add the reaping gallery rows for so if enter example number 2 i would to pupolate for me two line on gallery, so on so forth, 

 

at moment i have to click button each time i need another line on the gallery and i use that collection on my last post

 

Thanks 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

OK @Ramole ,

You could do this - a bit clunky, but just keep adding rows as the numbers increase

If(
   Value(
      YourNumberFieldName.Text
   )>0,
   Collect(
      NewShipCollection,
      {
         CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
         Clevel: "",
         Ctc: "",
         Cdescription: ""
      {
   )
)
);
If(
   Value(
      YourNumberFieldName.Text
   )>1,
   Collect(
      NewShipCollection,
      {
         CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
         Clevel: "",
         Ctc: "",
         Cdescription: ""
      {
   )
);
If(
   Value(
      YourNumberFieldName.Text
   )>2,
  Collect(
      NewShipCollection,
      {
         CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
         Clevel: "",
         Ctc: "",
         Cdescription: ""
      {
   )
)

 

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.

Hi @WarrenBelz 

 

This is the error i get on the screen shot 

 

Thanks 

 

 

error23.png

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

@Ramole ,

I copied your code and simply repeated it three times with the number logic.

I cannot see under the error, but you must have a bracket wrong somewhere.

v-siky-msft
Community Support
Community Support

Hi @Ramole,

 

Could you please try this?

1. Set App.OnStart: ClearCollect(ColNum,[1,2,3,4,5,6,7,8,9,10]) // asume the maxiumn of Number Package field is 10

2. Modify the OnChange of Number Package Textinput box as below, it creates new rows repeatedly based on the values you enter.

 

ForAll(
FirstN(ColNum,Value(DataCardValue60_2.Text)),
Collect( NewShipCollection,
{CItemSerialNumber: Text(Last(NewShipCollection).CItemSerialNumber + 1),
Clevel: "",
Ctc: "",
Cdescription: ""
}))

 

 Hope this helps.

Sik

@Ramole ,

I will leave you with @v-siky-msft on this one

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,361)