I should note that the ternaries used in this are part of the troubleshooting...they were not used originally.
The only hint of a possibility is that I have so far only been able to make it fail when the tag-text begins with a numeric character. But even this does not ALWAYS fail.
It appears to see it as a non-listed item so therefore uses the text entered as the value. The only reason I can think of is that it is only looking in a certain number of items
The max-items only limits the number of items that is shown in the autocomplete droplist.
I'm trying to reproduce the issue but currently have no success with that. If there is more information when it fails then perhaps I could pinpoint the problem, currently I have no idea where to search.
@patrick This is happening to me as well. It appears to happen when there is a space at the beginning or end of the value for the tag-text runtime element.
@bpj and @mebeingken, could you see if that is the cause for you?
As an example, the First Name has a space at the end. If I remove it, then the form submits successfully. If I add it back it gets the error. I've validated with multiple records and this happened consistently.
Sorry, the updated code didn't fix the issue. I have included a short video below to show what happens when I type the product code 96560 and press enter to select it. It changes to Product Code 33027, which is actually product_id of the product code that I had originally typed.
Thanks for the updated code. This has resolved the issue partially.
When selecting the product codes originally, the product id values are correct. I have included a screenshot with two sets of original product codes - Code 96560 & 74938
When I edit the same workorder, the values get swapped with product id of the original product code. Please note Code in the 1st line has changed to 33027 and Code in the 3rd line has changed to 12065. However, the Product Descriptions have remained for the original codes.
Upon checking the dev console, I can see only two server connect API calls to workorder_form_product_selected, instead of making/repeating 4 calls for each line record.
I have just tested the latest code, and everything is now working correctly at all stages - both during the initial code selection and when editing an existing record.
Thank you for resolving this bug so promptly, I really appreciate it.