cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

@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.
Check out my PowerApps Videos too!

@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 🙂

@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.
Check out my PowerApps Videos too!

@RandyHayes 

 

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

 

 

@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.
Check out my PowerApps Videos too!

Helpful resources

Announcements
News & Announcements

Community Blog

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

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,611)