IF THIS.IsNew() THIS.ResetPrimaryFlag() && Reset previous records Primary flag to 0 REPLACE cPointer_fk WITH v_patients.cPatients_pk, ; cPointer_table_name WITH 'PATIENTS', ; cUsgrlink_fk WITH THISFORM.cUsgrlink_fk , ; iPrimary_flag WITH 1 this.cAction_Code = "AD" ELSE REPLACE cUsgrlink_fk WITH THISFORM.cUsgrlink_fk this.cAction_Code = "CH" ENDIFWhere ResetPrimaryFlag method is:
*---------------------- Location Section ------------------------ * Library: Abizness.vcx * Class: Abizobj * Method: Resetprimaryflag() *----------------------- Usage Section -------------------------- *) Description: *) * Scope: Public * Parameters: *$ Usage: *$ * Returns: *--------------------- Maintenance Section ---------------------- * Change Log: * CREATED 07/07/2005 - WGB * MODIFIED *---------------------------------------------------------------- LOCAL loSelect, lnCurRec, lcAlias loSelect = THIS.SelectAlias() IF RECCOUNT() > 1 lnCurRec = RECNO() && Save the current record lcAlias = ALIAS() && primary view of the biz object *REPLACE iPrimary_flag WITH 0 FOR iPrimary_flag = 1 UPDATE (lcAlias) SET iPrimary_flag = 0 WHERE iPrimary_flag = 1 GOTO lnCurRec && Return to the record ENDIFI found, that this code is not reliable and in some cases is not working at all. I can not see, what exactly is wrong with it.
IF THIS.IsNew() * THIS.ResetPrimaryFlag() && Reset previous records Primary flag to 0 local lcEmployers_pk lcEmployers_pk = cEmployers_pk && Save new record's PK REPLACE cPointer_fk WITH v_patients.cPatients_pk, ; cPointer_table_name WITH 'PATIENTS', ; cUsgrlink_fk WITH THISFORM.cUsgrlink_fk , ; iPrimary_flag WITH iif(cEmployers_pk == m.lcEmployers_pk,1,0) all ELSE REPLACE cUsgrlink_fk WITH THISFORM.cUsgrlink_fk ENDIFand this seems to work fine so far.