[RESOLVED] - Code in OnFindRecord in Customer Card

BorisKBorisK Member Posts: 45
Can someone explain the purpose of the code in OnFindRecord in Customer Card:

RecordFound := FIND(Which);
CurrForm.EDITABLE := RecordFound OR (GETFILTER("No.") = '');
EXIT(RecordFound);

It was introduced in version 4.00. It appears to cause performance issues in one of our databases and I can't see any adverse effects if I remove it (and local variable RecordFound!).
Perhaps it is used when Customer Card is opened from somewhere else - but where?

Comments

  • koubekkoubek Member Posts: 84
    It helps to protec Customer evidence from inserting unwanted records... If You omit line
    CurrForm.EDITABLE := RecordFound OR (GETFILTER("No.") = '');
    
    , you can set filter on primary key (field No.) and if nothing exist for this filter, you can enter some data and insert new record... Nothing more. Try It..
  • BorisKBorisK Member Posts: 45
    Hmmm... :?
    Thanks for the reply but I am not sure what you mean.
    You can't set a filter for "No." anyway because it will be reset by

    Form - OnAfterGetRecord()
    SETRANGE("No.");

    Any more ideas anyone?
  • koubekkoubek Member Posts: 84
    Try to change code like this:
    RecordFound := FIND(Which);
    EXIT(RecordFound);
    {
    CurrForm.EDITABLE := RecordFound OR (GETFILTER("No.") = '');
    EXIT(RecordFound);
    }
    
    or (it doesn`t matter which one, thre result will be the same)
    RecordFound := FIND(Which);
    //CurrForm.EDITABLE := RecordFound OR (GETFILTER("No.") = '');
    EXIT(RecordFound);
    
    and then set filter on "No." field... You can see difference between standard and modified solution.
  • kapamaroukapamarou Member Posts: 1,152
    BorisK wrote:
    It appears to cause performance issues in one of our databases

    What type of performance issues does this cause? It shouldn't.
  • BorisKBorisK Member Posts: 45
    I know it shouldn't but it seems to take awfully long time on the first line (FIND). May be nothing to do with code as such but I thought I would ask. Anyway - any more ideas what this code is for?
  • kapamaroukapamarou Member Posts: 1,152
    As proposed try it and you will see.

    If you filter for customer XXXXXXXYYYYYY and no such customer exists, your form will displayy a new record with XXXXXXXYYYYYY code. If you move to another field and type something your record might be inserted. So this code sets the form to non-editable if you filter for a customer that does not exist in order to avoid this.

    Regarding the performance issue use your client monitor to see where the problem is.
  • BorisKBorisK Member Posts: 45
    OK, I got it now.
    Thank you both, this is all I need to know!
Sign In or Register to comment.