If you create an Invoice you could use the great Search function to select products.
But what to do, if you store your unique product selector in a field, which won't be searched during this function?
You probably could apply the following modification:
But you probably will need some SQL knowledge!
if($module == 'Products'){ $query = 'SELECT label, crmid, setype, createdtime FROM vtiger_crmentity INNER JOIN vtiger_products ON vtiger_products.productid = vtiger_crmentity.crmid WHERE label LIKE ? AND vtiger_crmentity.deleted = 0 AND vtiger_products.discontinued = 1 AND setype = ?'; }else if($module == 'Services'){ $query = 'SELECT label, crmid, setype, createdtime FROM vtiger_crmentity INNER JOIN vtiger_service ON vtiger_service.serviceid = vtiger_crmentity.crmid WHERE label LIKE ? AND vtiger_crmentity.deleted = 0 AND vtiger_service.discontinued = 1 AND setype = ?'; }
Customize this queries, like you need.
If you will query a custom fields (in this example cf_645), you need to modify the code in this way:
if($module == 'Products'){ $query = 'SELECT label, crmid, setype, createdtime FROM vtiger_crmentity INNER JOIN vtiger_products ON vtiger_products.productid = vtiger_crmentity.crmid INNER JOIN vtiger_productcf ON vtiger_products.productid = vtiger_productcf.productid WHERE (label LIKE ? OR cf_645 LIKE ?) AND vtiger_crmentity.deleted = 0 AND vtiger_products.discontinued = 1 AND setype = ?'; $params[] = "%$searchKey%"; }else if($module == 'Services'){ $query = 'SELECT label, crmid, setype, createdtime FROM vtiger_crmentity INNER JOIN vtiger_service ON vtiger_service.serviceid = vtiger_crmentity.crmid WHERE label LIKE ? AND vtiger_crmentity.deleted = 0 AND vtiger_service.discontinued = 1 AND setype = ?'; }