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:
- Function
- Function_ID (Text)
- Function_Description (Text)
- Adoption:
- Customers
- CustomerFunctionAdoption
- Customer (Lookup from Customers)
- Function_Description (Lookup from Function)
- Adoption (Lookup from Adoption)
- Adoption_Text (Text field)
Screen
- Customer Dropdown: Items - built using SortByColumns(Customers,"Customer")
- Gallery - Loaded from the Function table
- Function_ID - saved into a label in the gallery
- Function_Description - saved into a label in the gallery
- Adoption Drop-Down list
- Items - built using Distinct(Adoption,Adoption_Level)
- Default set with a Lookup(CustomerFunctionAdoption,CustomerDropdown.Selected.Title in Customer.Value && Function_ID.Text in Function_ID.Value,Adoption_Level.Value) <- there is other IF logic around this
- OnChange - This is where I'm having issues - What I'm trying to accomplish is when the dropdown is changed, then I either look up the existing record and upate the value in the table with the new value from the dropdown, or I create new record and populate the Customer, Function and Adoption value. The command works if I'm updating a standard 'Text' field in the SharePoint listing - but when I try to set the value to the Lookup field I get an error:
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!