WODA: FAQs

 Data Management

How do I know if a record is new or old?
Dear woda lovers,

As you know I dislike solution that are not WODA consistent even though they work! Therefore I do not suggest solution using variablels that are not globals (I mean considered globals by woda and for which ziga will keep consistency) and that could be changed in future versions.

To know if a record is new or already existing I suggest the following

Add this field to the definition file:

$x='exist';
$WBF{$x,srt}=$i--;
$WBF{$x,'type'} = 'INPUT';
$WBF{$x,'typePar'} = 'HIDDEN';
$WBF{$x} = '1;';
$WBF{$x,'d'} = '&NOOP();"$rec{_id}"'; #BE CAREFUL WITH THE QUOTES HERE

Note that &NOOP(); is a true woda function that does nothing. Why you need it? The string must start with an & to be evaluated.

When the record is created for the first time this field will be empty since $rec{_id} does not exist; When you edit the record, the field will be filled with the id value.

then:

sub myafterTableModify_funcion {

if ($rec{exist}) {
do this; #THE RECORD IS OLD
}
else {
do that; #THE RECORD IS NEW
}
}

PS. this and that are just words you should put something there.


--
claudio
modify the informationdelete entire recordexplain the meaning of the fieldsbrowse recordsAdd a new questionHome page of this databaselogin Valid HTML 4.01 Transitional Valid CSS! Powered by WODA 4.6x trunk