I'm trying to update a record or add a new record in the table 'CustomerFunctionAdoption' based on the value selected from a dropdown. When that dropdown changes, the OnChange will either find the record and update a single field, or create a new record populating the entire record. I've run into an issue because all of the fields in the 'CustomerFunctionAdoption' table are SharePoint lookup values from other existing tables. I didn't think my function was working until I added a new field that was strictly text and it finds the record in the table and updates the text field. How do I have sharepoint do the lookup for me based on the text value I'm passing?
Context:
Tables:
Screen
The type of this argument 'Adoption' does not match the expected type 'Record'. Found type 'Error'
When I change it to 'Adoption_Text' it finds the record in the table and updates that field.
I'm guessing from the message that because the 'Adoption' field is a lookup, it's looking for the internal ID to place in the field rather than the value? How do I have SharePoint do the lookup for me based on the text I'm trying to pass?
Thanks!
Solved! Go to Solution.
I've obviously been looking at this way too long today. I have it working - here is the final expression:
If(LookUp(CustomerFunctionAdoption,'CMB:SelectCustomer'.Selected.Title in Customer.Value && 'CMB:SelectSuccessEngagement'.Selected.Title in Success_Engagement.Value && Function_Code.Text in Function_ID.Value,"Update") = "Update",Patch(CustomerFunctionAdoption,First(Filter(CustomerFunctionAdoption, Customer.Value='CMB:SelectCustomer'.Selected.Title && Success_Engagement.Value='CMB:SelectSuccessEngagement'.Selected.Title && Function_ID.Value=Function_Code.Text)),{Adoption_Level:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Customer_Usage.Selected.ID,Value:Customer_Usage.Selected.Value}}),Patch(CustomerFunctionAdoption,Defaults(CustomerFunctionAdoption),{Customer:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:'CMB:SelectCustomer'.Selected.ID,Value:'CMB:SelectCustomer'.Selected.Title}},
{Success_Engagement:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:'CMB:SelectSuccessEngagement'.Selected.ID,Value:'CMB:SelectSuccessEngagement'.Selected.Title}},
{Function_ID:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:LookUp(D365Functions,Function_Code.Text in Title,ID),Value:Function_Code.Text}},{Adoption_Level:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Customer_Usage.Selected.ID,Value:Customer_Usage.Selected.Value}}))
Check this out. LookUp columns and PowerApps aren't friends for sure. But it is possible.
I was able to figure out the Patch for an update - I was missing the @odata.type syntax.
Now I'm running into issues with the Patch 'Add' - where I set the Default values. I have checked every entry and have the lookup information needed. As far as the 'Standard' fields (create date/time, create user, ID, etc.) are these all populated using the Defaults() function or do I have to provide the information?
I've obviously been looking at this way too long today. I have it working - here is the final expression:
If(LookUp(CustomerFunctionAdoption,'CMB:SelectCustomer'.Selected.Title in Customer.Value && 'CMB:SelectSuccessEngagement'.Selected.Title in Success_Engagement.Value && Function_Code.Text in Function_ID.Value,"Update") = "Update",Patch(CustomerFunctionAdoption,First(Filter(CustomerFunctionAdoption, Customer.Value='CMB:SelectCustomer'.Selected.Title && Success_Engagement.Value='CMB:SelectSuccessEngagement'.Selected.Title && Function_ID.Value=Function_Code.Text)),{Adoption_Level:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Customer_Usage.Selected.ID,Value:Customer_Usage.Selected.Value}}),Patch(CustomerFunctionAdoption,Defaults(CustomerFunctionAdoption),{Customer:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:'CMB:SelectCustomer'.Selected.ID,Value:'CMB:SelectCustomer'.Selected.Title}},
{Success_Engagement:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:'CMB:SelectSuccessEngagement'.Selected.ID,Value:'CMB:SelectSuccessEngagement'.Selected.Title}},
{Function_ID:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:LookUp(D365Functions,Function_Code.Text in Title,ID),Value:Function_Code.Text}},{Adoption_Level:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Customer_Usage.Selected.ID,Value:Customer_Usage.Selected.Value}}))
User | Count |
---|---|
134 | |
131 | |
97 | |
77 | |
74 |
User | Count |
---|---|
206 | |
197 | |
69 | |
59 | |
52 |