so what you can do is for item A, having serial 1234, you can make a search based on your mapping table, select 1st lineitem i.e. item A, check its serial via inventorydetail subrecord, which will fetch you 1234 and then query your search with itemA and serial no 1234 as filter which will fetch you its price and then set it on line 1st line. You can do this via beforesubmit . I suggest avoid client script.