Page 1 of 1

Virtual Field

Posted: Fri Jan 20, 2023 10:31 am
by mishanian

Hi,
I have a table with the following column:

id, name, code

I would like to generate code dynamically as a virtual field and use it in SEARCH

function Row_Rendering()
{
if(id>10){
	$this->code->CurrentValue=1;
}else{
	$this->code->CurrentValue=2;
}

and use Extend Search for searching code=1
is it possible without creating a view as the original concept is too complex?


Re: Virtual Field

Posted: Fri Jan 20, 2023 10:51 am
by arbei

You may use Custom Field.


Re: Virtual Field

Posted: Fri Jan 20, 2023 11:34 am
by mishanian

Thanks for your response.

can I update it by CurrentValue?

$this->code->CurrentValue=2;

and is it better to use Row_Rendering or Row_Rendered function?


Re: Virtual Field

Posted: Fri Jan 20, 2023 12:33 pm
by mishanian

I created a Custom Field.
and now it works on Row_Rendering function

function Row_Rendering()
{
if(id>10){
	$this->code->CurrentValue=1;
}else{
	$this->code->CurrentValue=2;
}

Still, when I use ** Extend Search** for code=1 can not find any record


Re: Virtual Field

Posted: Fri Jan 20, 2023 12:40 pm
by arbei

You should use a SQL expression for the custom field to get the value from the database directly, not by server event, see the example in the docs.