Page 1 of 1

Using a calculated field for an Auto-fill lookup.

Posted: 2024-02-07 07:20
by kmullins
This might be a known condition; I couldn't find anything after some searching on the forum.

I tried to use a calculated field from one table as an auto-fill lookup in another. I can get other fields to auto-fill from the same relationship, just not my calculation, which sums values from another table.

As a workaround, would there be a way I could copy the calculated value into a non-calculated field leveraging the hooks file? Would some update command to save the value to the database?

Would this be how I would do that?

Code: Select all

	
	function Catalog_after_insert($data, $memberInfo, &$args) {
		$data['ValueStatic'] = $data['ValueCalculation']
		return TRUE;
	}
Thanks for any guidance.
Kevin

Re: Using a calculated field for an Auto-fill lookup.

Posted: 2024-02-07 07:47
by kmullins
Reading other posts, I know my first thought on the code is wrong.
I also forgot the version info: Appgini 24.10 rev 1579

Is this better?

Code: Select all

	function Catalog_after_insert($data, $memberInfo, &$args) {
		 $calc = $data['ValueCalculation'];
       		 sql("update CATALOG set ValueStatic='{$calc}' where id=%ID%", $eo);
		return TRUE;
	}