Only Lookup must work

omyvadiyaomyvadiya Member Posts: 124
Hi,
I have written a lookup code on a field, but if user types, it isn't validating the data that is being typed.

Somehow, it can be that either the written text is validated from the page that is opening on lookup or writing anything is not allowed??

Best Answer

  • omyvadiyaomyvadiya Member Posts: 124
    Answer ✓
    Its done.
    Just have to use the below kind of code for such cases:
    IF "Account Type" = "Account Type"::"G/L Account" THEN BEGIN
    GLAccount1.INIT;
    IF "Account No." <> '' THEN
    GLAccount1.GET("Account No.");//Over here it will give u the error, where it checks it existence..still i guess, how it will work for non primary keys??
    END;

Answers

  • omyvadiyaomyvadiya Member Posts: 124
    Answer ✓
    Its done.
    Just have to use the below kind of code for such cases:
    IF "Account Type" = "Account Type"::"G/L Account" THEN BEGIN
    GLAccount1.INIT;
    IF "Account No." <> '' THEN
    GLAccount1.GET("Account No.");//Over here it will give u the error, where it checks it existence..still i guess, how it will work for non primary keys??
    END;
  • vaprogvaprog Member Posts: 1,139
    Your code looks strange to me. I don't know where you placed that code, though.

    Nevertheless, there are two fundamentally different kinds of lookup triggers, those on table fields, and those on controls on Pages.
    • In the OnLookup trigger of a table you always should use VALIDATE to set the field's value.
      ...
      IF PAGE.RUNMODAL(0,MyRec) = ACTION::LookupOK THEN
        VALIDATE(MyField,MyRec.Code);
      
    • In the OnLookup trigger of a page, you should always assign the value to Text and return TRUE. Lookup then just fills in the value into the control, and normal processing occurs when you leave the control, just as if you entered the value from the keyboard. This behavior is identical to a field for which you just set the TableRelation property and NAV is using the LookupPageID of the related table. You cannot achieve the same behavior when using a lookup trigger implemented on the table field.
      ...
      IF NOT (Page.RUNMODAL(0,MyRec) = ACTION::LookupOK THEN
        EXIT(FALSE);
      Text := MyRec.Code;
      EXIT(TRUE);
      
  • omyvadiyaomyvadiya Member Posts: 124
    My motive was to stop users from writing any text, instead they must open the page and select the values. And .GET did that
Sign In or Register to comment.