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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,699)