Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Making Multiple Changes to the Primary Alias
Message
 
À
16/04/2002 17:42:13
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00645739
Message ID:
00645763
Vues:
9
>I have a business object, phoneobj, with v_phone as its primary view. It stores phone numbers for a contact. It has a "primary" field, which indicates if the record is the primary phone number. If a user adds or edits a phone number and selects the primary=.t., I want to change the existing primary to .f.
>
>I tried putting code in the post-save hook:
>
>if primary
> lnRecno=recno()
> replace all primary with .f. for recno()#lnRecno
> go lnRecno &&Return to original record
>endif
>
>That doesn't work - causes update conflicts, which in retrospect, makes sense.
>
>I also tried changing the buffering to optimistic table, which doesn't solve the problem. Any ideas how to do this?
>
>Thanks,
>
>David

Assuming v_phone is table buffered, and is a parameterized view (maybe based on the contact PK), you could add code to the form that calls a bizobj method to automatically switch the others to .F. when the user selects the "Primary" option. Where you do that in the form really depends on how the form is set-up, though.

You could also do this in the PreSaveHook() method.

I've seen other developers use triggers in the DBC to do the same thing. The one problem with that approach is that it was a major hassle to trace that code down (when you don't know the triggers exist) if there is a problem. It also might not be a great fit for alternative backends.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform