Values are not inserting in onlookup trigger

thankeshthankesh Member Posts: 170
Hi,

I have a new field "Team code" in table 13. But, the values are not getting populated in the new table "TeamSalesPerson".

PF the code below...

Team Code - OnLookup()

IF Code <> '' THEN
RecTeamSalesPerson.SETRANGE(RecTeamSalesPerson."Salesperson Code",Code);
IF RecTeamSalesPerson.FINDFIRST THEN BEGIN
IF (FORM.RUNMODAL(FORM::"Teamwise Salesperson List",
RecTeamSalesPerson,RecTeamSalesPerson."Salesperson Code") = ACTION::LookupOK) THEN
"Team Code" := RecTeamSalesPerson."Team Code";
END
ELSE
IF (FORM.RUNMODAL(FORM::Teams,
RecTeam,RecTeam.Code) = ACTION::LookupOK) THEN BEGIN
"Team Code" := RecTeam.Code;
RecTeamSalesPerson.INIT;
RecTeamSalesPerson."Team Code" := "Team Code";
RecTeamSalesPerson."Salesperson Code" := Code;
RecTeamSalesPerson.INSERT;
END;

:-k
With warm regards,

Thankesh

***Learn to lead***

Comments

  • ReinhardReinhard Member Posts: 249
    I'm not sure based on your description what the problem is.
    When you do a FORM.RUNMODAL you don't see any values to select from, or after you select a value, you don't see any changes being made on the salesperson rec?

    I would recommend indenting your code for legibility. Personally, I like to do it like this. Even though it causes small problems for merging..... [-X
    IF Code <> '' THEN
      RecTeamSalesPerson.SETRANGE(RecTeamSalesPerson."Salesperson Code",Code);
    
    IF RecTeamSalesPerson.FINDFIRST THEN 
    BEGIN
      IF (FORM.RUNMODAL(FORM::"Teamwise Salesperson List",RecTeamSalesPerson,RecTeamSalesPerson."Salesperson Code") = ACTION::LookupOK) THEN
        "Team Code" := RecTeamSalesPerson."Team Code";
    END 
    ELSE IF (FORM.RUNMODAL(FORM::Teams,RecTeam,RecTeam.Code) = ACTION::LookupOK) THEN 
    BEGIN
      "Team Code" := RecTeam.Code;
      RecTeamSalesPerson.INIT;
      RecTeamSalesPerson."Team Code" := "Team Code";
      RecTeamSalesPerson."Salesperson Code" := Code;
      RecTeamSalesPerson.INSERT;
    END;
    
  • kapamaroukapamarou Member Posts: 1,152
    Are you testing the lookup from the table or a form?
  • thankeshthankesh Member Posts: 170
    kapamarou wrote:
    Are you testing the lookup from the table or a form?
    Testing the lookup from the table.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kapamaroukapamarou Member Posts: 1,152
    Try through a form.
  • thankeshthankesh Member Posts: 170
    kapamarou wrote:
    Try through a form.
    How to achieve it through form?
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kapamaroukapamarou Member Posts: 1,152
    Do you run the table from the object designer, go to the field and press the lookup button or you have a form based on that table which you use to run the field's lookup?
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • thankeshthankesh Member Posts: 170
    I tried through forms. It works. :thumbsup:
    With warm regards,

    Thankesh

    ***Learn to lead***
Sign In or Register to comment.