Hi Everyone,
I want to update a value of a ComboBox(CB1) based on the selected value of the another ComboBox(CB2)in the EditForm.
I have the CB1 ComboBox (It holds the ProductID) in the default DataCard created by the EditForm. I have added a custom DataCard which has the CB2 ComboBox (It holds the ProductName).
So when I select the ProductName in CB2, I want to update the ID in the CB1 ComboBox through code.
I have used the below code in the DefaultSelectedItems property of CB1 which updates the ProductID in the CB1. For testing purpose, I have just checked whether particular item num is present and then assigned its ProductID to the CB1. I have populated the Items for CB1 as Choices([@Product_Suites].ProductID). So the assigning value type is also same as the items populated in the CB1. Products and Product_Suites are lists in the SharePoint.
If(
CB2.Selected.Title in Products.Title,
{
Value: LookUp(Product_Suites, ItemNumber = 55555, ProductID)
},
Parent.Default
)
When I add a new item, the ProductID is updated correctly in the view as when I select a ProductName. But the issue is that when I click the Save button which just invokes the SubmitForm function, the new item is not getting saved and showing error on the top as below for the 1st time. When I click Save again it just stays on the same screen:
Update:
Maybe this error is because the ProductID field is a Required field in the SharePoint list. Hence maybe the error. If it is Not a Required field then I guess, the field is saved as Empty instead of the value that is getting set from the above code snippet.
Error on 1st time:
"An error occurred on the server. Server Response: Product_Suites failed. BadGateway"
However, then when I unselect and select the ProductID manually using my mouse, then the new item is getting saved correctly. I don't know whether I am missing anything here or in their corresponding DataCard. So can anyone please help me out here?
Solved! Go to Solution.
Hi @sgokul95
Set the DefaultselectedItems property of CB1 to
If(IsBlank(CB2.Selected.Title),Parent.Default,
{
Value: LookUp(Product_Suites, ProductName = CB2.Selected.Title, ProductID)
}
)
Set the Update property of CB1 to
CB1.Selected
Thanks,
Stalin - Learn To Illuminate
Hi @sgokul95
Set the DefaultselectedItems property of CB1 to
If(IsBlank(CB2.Selected.Title),Parent.Default,
{
Value: LookUp(Product_Suites, ProductName = CB2.Selected.Title, ProductID)
}
)
Set the Update property of CB1 to
CB1.Selected
Thanks,
Stalin - Learn To Illuminate
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
User | Count |
---|---|
206 | |
97 | |
60 | |
51 | |
45 |
User | Count |
---|---|
258 | |
158 | |
85 | |
79 | |
58 |