Default value for add new record

Hi,

How can i set the default value of a field when adding a new record ?

Specificaly i have a UUID field that id like fill using the result of a SQL SELECT statment ( mariadb ).

if I use the following in the beforeinsert event it works fine but obviously the UUID field on the form remains blank

If ({uuid} == ‘’) {
$sql_next_rec=“SELECT UUID()”;
sc_lookup(rs, $sql_next_rec);
if (isset({rs[0][0]})) // Row found
{
{uuid} = ({rs[0][0]}) ;
}
}

any help appreciated

cheers

Try moving your code to the onLoad event of the form.
If that fails, try testing for if(empty({uuid})) instead of checking if it’s equal to ‘’.

Typical, the only event i didn’t try :slight_smile:

Thanks robydago