DELETEALL bug ?

EugeneEugene Member Posts: 309
in a form i do the following call:

LRec.SetMyGlobalVariable(TRUE);
LRec.DELETEALL(TRUE);

here LRec is a recordset
in the underlying table i have the following:

1) globaly defined boolean variable
bMyGlobalVariable

2) its access functions:

SetMyGlobalVariable(NewValue:Boolean);
begin
bMyGlobalVariable := NewValue
end;

GetMyGlobalVariable:Boolean;
begin
EXIT(bMyGlobalVariable);
end;

3) and the message in the OnDelete trigger of the table
MESSAGE(FORMAT(GetMyGlobalVariable))


what the problem is the message in the OnDelete trigger always returns FALSE

Is this a bug ?
Does the DELETEALL creates another copy of LRec to perform all the deletes:
LRec.SetMyGlobalVariable(TRUE);
LRec.DELETEALL(TRUE);

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I have not tested it but you might be right. I don;t know if it is a bug or if it is just supposed to work that way.

    What is the reason you want this to work different than it does? It is an interessting subject.
  • EugeneEugene Member Posts: 309
    basically i have USERID and timestamp fields in the table to keep the track on who was the last to modify the record.
    Then i don't want other users to be allowed to modify or delete the record (i check for this in onmodify and ondelete triggers)
    But in one special case this rule should be overriden hence the reason for the global variable to let bypass the rule:
    LRec.SetMyIgnoreUserVar(TRUE);
    LRec.DELETEALL(TRUE);
    LRec.SetMyIgnoreUserVar(FALSE);
    
    LRec.OnDelete trigger:
      IF NOT MyIgnoreUserVar THEN 
        IF DifferentUser THEN
          ERROR('You are not allowed to delete the record')
      DoSomeOtherThings;
    
Sign In or Register to comment.