main logo
Subject: Best Practise - Creating Default records, .New() .Save() doesn't, INSERT INTO does
Author: Bhavbhuti Nathwani
Posted: 2002/02/12 23:43:31
 
View Entire Thread
New Search


Hi All,

I wanted to created default records when the apps start, this is what I have done.

PostDoProcessingHook()
THIS.DefaultMAccounts()


DefaultMAccounts()
LOCAL loBO, lnTemp

loBO = CREATEOBJECT("bo_mAccounts")

SELECT mAccounts

COUNT TO lnTemp FOR !DELETED()

IF lnTemp = 0
THIS.CreateMAccounts(loBO, "Manufacturing A/c.", .T., 0, "", 0)
lnTemp0 = mAccounts.iID

* this works well
*INSERT INTO mAccounts (cName, lAcctHead, yOpBal, cCity, iPID), ;
* VALUES (loBO, "Manufacturing A/c.", .T., 0, "", 0)


THIS.CreateMAccounts(loBO, "Debit", .T., 0, "", lnTemp0)
lnTemp1 = mAccounts.iID

* this works well
*INSERT INTO mAccounts (cName, lAcctHead, yOpBal, cCity, iPID), ;
* VALUES (loBO, "Debit", .T., 0, "", lnTemp0)


... etc ...
ENDIF


CreateMAccounts()
LPARAMETERS toBO, tcName, tlAcctHead, tyOpBal, tcCity, tiPID

toBO.New()

REPLACE cName WITH tcName, ;
lAcctHead WITH tlAcctHead, ;
yOpBal WITH tyOpBal, ;
cCity WITH tcCity, ;
iPID WITH tiPID

toBO.SAVE()

FLUSH
Regards
Bhavbhuti
 
©2002 Bhavbhuti Nathwani
<-- Prior Message New Search Next Message -->