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

ForAll looping through users to write entries for each user - writing the same name every loop problem

I'm a complete novice to Power Apps and the entire Microsoft environment. I do have programming experience however.

I've been working on this canvas app as my first assignment. The idea is to have an app where the IT manager can assign IT equipment to employees. It is working properly, but I want the manager have the option of simply picking multiple users if they bought i.e. new phones for 10 employees, instead of having to do all the step 10 times. 

My code is processing, but it writes the first user to all entries in the loop. I'm used to the terminology as follows:

 

 

for i in users:
    print(users[i])

 

 

But it doesn't seem to work unfortunately. 

How do I assign the name appropriate to the user it is looping over?

 

My code:

 

 

ForAll(DataCardValue10.SelectedItems,
    Patch(
        'IT Assets',
        Defaults('IT Assets'),
        {
            'IT Model': LookUp(
                'IT Models',
                Brand = DataCardValue1.Selected.Result And Model = DataCardValue2.Selected.Model
            ),
            Condition: Dropdown2.Selected.Value,
            Price: Int(DataCardValue4.Text),
            Name: Concatenate(
                DataCardValue1.Selected.Result,
                " ",
                DataCardValue2.Selected.Model
            ),
            User: LookUp(
                Users,
                'Full Name' = DataCardValue10.Selected.'Full Name'
            )
        }
    )
)

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you for helping. I found another solution by trial and error. I went with this solution:

ForAll(DataCardValue10.SelectedItems,
    Patch(
        'IT Assets',
        Defaults('IT Assets'),
        {
            'IT Model': LookUp(
                'IT Models',
                Brand = DataCardValue1.Selected.Result And Model = DataCardValue2.Selected.Model
            ),
            Condition: Dropdown2.Selected.Value,
            Price: Int(DataCardValue4.Text),
            Name: Concatenate(
                DataCardValue1.Selected.Result,
                " ",
                DataCardValue2.Selected.Model
            ),
            User: ThisRecord
        }
    )
)

 

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @kenneth_here ,

Try the below

ForAll(
   DataCardValue10.SelectedItems As aPatch,
   Patch(
      'IT Assets',
      Defaults('IT Assets'),
      {
         'IT Model': 
         LookUp(
            'IT Models',
            Brand = DataCardValue1.Selected.Result And 
            Model = DataCardValue2.Selected.Model
         ),
         Condition: Dropdown2.Selected.Value,
         Price: Int(DataCardValue4.Text),
         Name: 
         Concatenate(
            DataCardValue1.Selected.Result,
            " ",
            DataCardValue2.Selected.Model
         ),
         User: 
         LookUp(
            Users,
            'Full Name' = aPatch.'Full Name'
         )
      }
   )
)

 

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.

Visit my blog Practical Power Apps

Thank you for helping. I found another solution by trial and error. I went with this solution:

ForAll(DataCardValue10.SelectedItems,
    Patch(
        'IT Assets',
        Defaults('IT Assets'),
        {
            'IT Model': LookUp(
                'IT Models',
                Brand = DataCardValue1.Selected.Result And Model = DataCardValue2.Selected.Model
            ),
            Condition: Dropdown2.Selected.Value,
            Price: Int(DataCardValue4.Text),
            Name: Concatenate(
                DataCardValue1.Selected.Result,
                " ",
                DataCardValue2.Selected.Model
            ),
            User: ThisRecord
        }
    )
)

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,728)