Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note: This USING statement is contained in the standard templates of the Business Entity Designer so that most Business Entities should contain this statement already.

Code Block
languagejavascriptprogress
linenumberstrue
USING Consultingwerk.OERA.*      FROM PROPATH .  
 
/*------------------------------------------------------------------------------
    Purpose: Provides a hook for high level data validation before Update 
             operations                                                                     
    Notes:   Invoked during SaveChanges (). When the ERROR flag of the ProDataset
             is set, the Update operation will be cancelled before writing back
             the data to the database using the DataAccess object                                                                      
------------------------------------------------------------------------------*/
METHOD OVERRIDE PUBLIC VOID ValidateData ():
    
    FOR EACH eCustomer ON ERROR UNDO, THROW:
 
        Validate:IsNotNullOrEmpty (BUFFER eCustomer:HANDLE, "Name":U, 
                                   MessageFormatter:GetMessage ("VALMSG":U, 1, "Customer Name")).
        
        IF 
	    Validate:IsNotNullOrEmpty (BUFFER eCustomer:HANDLE, "SalesRep":U, 
                                   MessageFormatter:GetMessage ("VALMSG":U, 1, "Sales Rep")) 
        THEN 
        Validate:CanFind (BUFFER eCustomer:HANDLE, 
                          "SalesRep":U,
                          "Consultingwerk.SmartComponentsDemo.OERA.Sports2000.SalesRepBusinessEntity":U,
                          "eSalesRep":U,
                          SUBSTITUTE ("FOR EACH eSalesRep WHERE eSalesRep.SalesRep = &1":U, 
                                      QUOTER (eCustomer.SalesRep)),
                          MessageFormatter:GetMessage ("VALMSG":U, 2, "Sales Rep", eCustomer.Salesrep)).
    END.
    
END METHOD.

...

You can see this when validating if the SalesRep field IsNotNullOrEmpty.

Code Block
languagejavafxprogress
linenumberstrue
Validate:IsNotNullOrEmpty (BUFFER eCustomer:HANDLE, "SalesRep":U, 
                           MessageFormatter:GetMessage ("VALMSG":U, 1, "Sales Rep")) .

...

As you can see in the sample above (full ValidateData method): if the field is filled with a value the next validation will take place. The second validation is to prove that the SalesRep entered exist in the DB.

Code Block
languagejavascriptprogress
linenumberstrue
Validate:CanFind (BUFFER eCustomer:HANDLE, 
                  "SalesRep":U,
                  "Consultingwerk.SmartComponentsDemo.OERA.Sports2000.SalesRepBusinessEntity":U,
                  "eSalesRep":U,
                  SUBSTITUTE ("FOR EACH eSalesRep WHERE eSalesRep.SalesRep = &1":U, 
                              QUOTER (eCustomer.SalesRep)),
                  MessageFormatter:GetMessage ("VALMSG":U, 2, "Sales Rep", eCustomer.Salesrep)) .

...