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

Reference to current record in UpdateIf

Hi everyone,

 

In my PowerApp i have a product and a product category. Because this powerapp is intergrated with other software i need a column which contains the productName and CategoryName combined. The category is a parent of the product. 

If i want to change the categoryName, i need to update all records in the combined column which have this category id. It is not a problem to filter these records although i don't know how to reference to the productName within the UpdateIf function. 

 

 

UpdateIf(
	ProductCollection, 
	Value(id_category) = Value(ProductGallery.selected.id), 
	{fullName: Concatenate(thisitem.productName," ",changedCategoryName.Text }
	);

 

 

I get an error in the Concatenate function (invalid arguments). I have also tried to come up with a LookUp function but don't know how to find the current row of the Updateif function. 

 

Any ideas? 

5 REPLIES 5
Highlighted
Super User
Super User

Re: Reference to current record in UpdateIf

@Mattie021 

 

You might want to consider this as an approach:

 

UpdateIf(
    ProductCollection, 
    id_category = ProductGallery.selected.id, 
    {
        fullName: Lookup(ProductCollection, id_category = ProductGallery.Selected.ID, productName) & " " & changedCategoryName.Text 
    }
);

 

Note: I removed the Value functions on the assumption that both id_category and the selected.ID are numbers.  If so, there is no need for the Value function.  If that assumption is incorrect, then use the Value function around whichever is not a number (i.e. text).

Also, you can shortcut with just the & character to concatenate.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Frequent Visitor

Re: Reference to current record in UpdateIf

@RandyHayes thank you for your reply.

 

With this LookUp filter i get the same (first) product name for every value it updates. I need to find the specific productName of the row which is updating. My current results now all look the same: 

 

Product a Category x

Product a Category x

...

 

While i am looking for:

Product a Category x

Product b Category x

...

 

Thank you for the other suggestions 🙂

Highlighted
Super User
Super User

Re: Reference to current record in UpdateIf

@Mattie021 

I misunderstood your original post then.

 

So, every item in your list should be updated with the original ProductName and the new Category (if it has the old category ID)? 

If that is the case, is there a unique ID for each record in your collection? 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Frequent Visitor

Re: Reference to current record in UpdateIf

@RandyHayes 

 

Yes that is correct! The products also have an unique ID. 

 

 

Highlighted
Super User
Super User

Re: Reference to current record in UpdateIf

@Mattie021 

Very good, that helps!

 

In that case, consider this formula:

ForAll(
    RenameColumns(
        Filter(
            ProductCollection, 
            id_category = ProductGallery.selected.id
        ), 
        "yourUniqueColumn", "renamedColumn"
    ),

    UpdateIf(ProductCollection,
        yourUniqueColumn = renamedColumn,
        {
            fullName: productName & " " & changedCategoryName.Text 
        }
    )
);

 

This will go through a Filtered list of items that have a category ID equal to the currently selected one in your Gallery.

It will then Update the Item (based on the unique column that you have) and set the FullName column to the original productName and the changed category name.

 

See if that does it for you now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,380)