Hi,
I have a simple inventory list in Sharepoint that was imported into a collection in PowerApp for the purpose of updating the products' inventory. I cannot for the life of me figure out how to overwrite the data in the Previous Inventory column with the data in the Current Inventory column.
I would prefer to work within the collection itself rather than copying the collection, liaising back and forth through share point - It's a bulk update - copy all records in one column to another.
Solved! Go to Solution.
Hi @ColinM ,
According to the needs that you mentioned, I think the ForAll function could achieve your needs. Based on the ForAll formula that you provided, I think there is something wrong with it.
I have made a test on my side, please consider modify your formula as below (set the OnSelect property of a button to following) :
ForAll(
RenameColumns(StartInventoryCollection, "ID", "ID1"),
Patch(
StartInventoryCollection,
LookUp(StartInventoryCollection, ID = ID1),
{
'Preivous Inventory': LookUp(StartInventoryCollection, ID = ID1, 'Current Inventory')
}
)
)
RenameColumns function, Patch function, ForAll function
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
@ColinM
Please provide sample data if my code doesn't work.
ClearCollect(
your_collection_name,
AddColumns(DropColumns(your_collection_name, "Previous Inventory"), "Previous Inventory", 'Current Inventory')
)
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi @ColinM ,
try this:
Patch(collectionName,ThisItem,{previousInventoryColum:CurrentInventorycolumn})
I am assuming you are clicking on a button as soon as you provide the latest column in a gallery.
If not you want to iterate through the list, below is the code for you:
ForAll(collectioName,Patch(collectionName,ID=ID,{previousInventoryColum:CurrentInventorycolumn}))
I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.
Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.
Hi,
ForAll has rebuffed my efforts noting it cannot operate on items it is trying to patch, and your code noted it expects a record value.
ForAll(StartInventoryCollection, Patch(StartInventoryCollection, ID = ID, {'Preivous Inventory': 'Current Inventory'}))
Attached is a copy of the imported collection from SharePoint.
Thanks
Colin
FORALL is not necessary. Just delete the column for Previous Inventory and add a new column called Previous Inventory with the values equal to the Current Inventory column as shown in my example above.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
I agree with @mdevaney to just copy the value and which will create a new collection with the value duplication. At the end if you want you can clear(old collection)
collection( oldcollection, new collection)
Regards,
Krishna
Hi @ColinM ,
According to the needs that you mentioned, I think the ForAll function could achieve your needs. Based on the ForAll formula that you provided, I think there is something wrong with it.
I have made a test on my side, please consider modify your formula as below (set the OnSelect property of a button to following) :
ForAll(
RenameColumns(StartInventoryCollection, "ID", "ID1"),
Patch(
StartInventoryCollection,
LookUp(StartInventoryCollection, ID = ID1),
{
'Preivous Inventory': LookUp(StartInventoryCollection, ID = ID1, 'Current Inventory')
}
)
)
RenameColumns function, Patch function, ForAll function
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
@v-xida-msft
Myself and @KrishnaV have already agreed that deleting the 'Previous Inventory' column and adding it back with the value of 'Current Inventory' is the way to go.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi,
Thank you everyone who helped - when I attempted to use the AddColumn/DropColumn code PowerApps informed me the column names already existed preventing me from going further. I broke the code down into steps where I could drop columns but adding the column proved impossible. It might have something to do with the imported list from SharePoint keeping its internal column name versus the name I had assigned to it.
Many thanks!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
53 | |
50 | |
36 | |
35 |
User | Count |
---|---|
271 | |
91 | |
82 | |
76 | |
75 |