According the logic you have written, it looks like that you are trying to store value of input text to the Sobject's lookup field. For example if you have TestG2
, you are trying to assign it to Lookup type field which ultimately trowwill throw exception when insert/update happen.
Reason is lookup fields always have Id
of the records instead of name. So, you typehead component showing those value must have Id behind as they are record of some object. Store and set that Id to inputText
instead of the name visible on page.