Hi everyone,
Does anyone know if it possible to Bulk create and Bulk update a SharePoint list with one button/one execution?
I have the following code working in the Gallery for single records. This will either create an item or update an item if the item already exists:
If(CountRows(Filter(DB_MarketFeedback, CustomerID = ThisItem.Customer)) > 0,
Patch(
DB_MarketFeedback,
LookUp(DB_MarketFeedback,CustomerID=ThisItem.Customer),
{
Title: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text
}),
Patch(
DB_MarketFeedback,
Defaults(DB_MarketFeedback),
{
Title: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text,
CustomerID: ThisItem.Customer
}))
I have following working to update all items in the Gallery:
ForAll(
Gallery1.AllItems,
Patch(
DB_MarketFeedback,
LookUp(
DB_MarketFeedback,
CustomerID = Customer
),
{
Validation_Status: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text
}
)
)
And I have the following working to create items in the Gallery:
ForAll(
Gallery1.AllItems,
Patch(
DB_MarketFeedback,
Defaults(DB_MarketFeedback),
{
Title: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text,
CustomerID: Customer
}
)
)
Any thoughts would be appreciated.
Best regards,
Ami
Solved! Go to Solution.
Hi @imranamikhan ,
Could you tell me:
I assume:
If my assumptions are correct, the point is to use the If() function to determine whether there is an existing record.
If so, modify the existing record. If not, create a new record.
I've made a test for your reference:
1\ This is my list “DB_MarketFeedback”. There are some test records in it .
2\ Add a gallery control and set its Items property to:
Table({Customer:1},{Customer:2},{Customer:3},{Customer:4},{Customer:5})
3\ Add a dropdown control “Dropdown_Status” and set its Items property to:
Table({Test:"Test1"},{Test:"Test2"})
4\ Add a Textinput control “TextInput_Comment” .
5\ Add a button control and set its onselect property to:
ForAll(
Gallery1.AllItems,
If(
CountRows(
Filter(
DB_MarketFeedback,
CustomerID = Customer
)
) > 0,
Patch(
DB_MarketFeedback,
LookUp(
DB_MarketFeedback,
CustomerID = Customer
),
{
' Validation_Status': Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text
}
),
Patch(
DB_MarketFeedback,
Defaults(DB_MarketFeedback),
{
Title: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text,
CustomerID: Customer
}
)
)
)
6\ The result is as follows:
Best Regards,
Wearsky
Hello @imranamikhan
The Gallery control does not support multi-selection, I think you can add a Checkbox control on your gallery, update OnSelect property with:
Collect(Selected,ThisItem)
That will create a collection with all selected items of the gallery, use UpdateIf to change the values then submit the changes with Forall and Patch.
Take a look in this article
https://sachinbansal.blog/2018/08/06/powerapp-cds-multi-select-items-in-gallery-using-checkbox-bulk-...
Hi @imranamikhan ,
Could you tell me:
I assume:
If my assumptions are correct, the point is to use the If() function to determine whether there is an existing record.
If so, modify the existing record. If not, create a new record.
I've made a test for your reference:
1\ This is my list “DB_MarketFeedback”. There are some test records in it .
2\ Add a gallery control and set its Items property to:
Table({Customer:1},{Customer:2},{Customer:3},{Customer:4},{Customer:5})
3\ Add a dropdown control “Dropdown_Status” and set its Items property to:
Table({Test:"Test1"},{Test:"Test2"})
4\ Add a Textinput control “TextInput_Comment” .
5\ Add a button control and set its onselect property to:
ForAll(
Gallery1.AllItems,
If(
CountRows(
Filter(
DB_MarketFeedback,
CustomerID = Customer
)
) > 0,
Patch(
DB_MarketFeedback,
LookUp(
DB_MarketFeedback,
CustomerID = Customer
),
{
' Validation_Status': Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text
}
),
Patch(
DB_MarketFeedback,
Defaults(DB_MarketFeedback),
{
Title: Dropdown_Status.SelectedText.Value,
Comment: TextInput_Comment.Text,
CustomerID: Customer
}
)
)
)
6\ The result is as follows:
Best Regards,
Wearsky
Thank you very much @v-xiaochen-msft. I was not clear on combining create and update in one execution and this is perfect.