Show record list from a different company

Djou2424Djou2424 Member Posts: 76
Hi,

I need help for one of our client.
We need to show the location list from a different company, in a form, and retrieve the record selected by the user into in a field.

Here is what I tried, but it is always showing me the location list of my current company.

recLoc.RESET; //record Location Code, temporary NO
CLEAR(frmLoc); // form Location List
CLEAR(tmpLoc);
tmpLoc.DELETEALL; //record Location Code, temporary YES

recLoc.CHANGECOMPANY("Company Name");
IF recLoc.FIND('-') THEN
REPEAT
tmpLoc := recLoc;
tmpLoc.INSERT;
UNTIL recLoc.NEXT = 0;

frmLoc.SETTABLEVIEW(tmpLoc);
IF frmLoc.RUNMODAL = ACTION::LookupOK THEN
BEGIN
frmLoc.GETRECORD(tmpLoc);
"Location Code" := tmpLoc.Code;
END;

What am I doing wrong?

Thanks
-Julie

P.S: I also tried setting the form view to the recLoc directly instead of the temporary table, same results.

Comments

  • FelixAntonyFelixAntony Member Posts: 6
    Try tmpLoc.changecompany("company name") before copying the records to temp variable
  • kinekine Member Posts: 12,562
    The probelm is that you are using SETTABLEVIEW. It is passing only filters, not the record itself.

    Try to do it easily:
    Loc.CHANGECOMPANY("another company");
    IF FORM.RUNMODAL(0,Loc) = ACTION::LookupOK THEN
    BEGIN
      "Location Code" := Loc.Code;
    END;
    

    You even do not need to use temporary table...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Djou2424Djou2424 Member Posts: 76
    kine wrote:
    The probelm is that you are using SETTABLEVIEW. It is passing only filters, not the record itself.

    Try to do it easily:
    Loc.CHANGECOMPANY("another company");
    IF FORM.RUNMODAL(0,Loc) = ACTION::LookupOK THEN
    BEGIN
      "Location Code" := Loc.Code;
    END;
    

    You even do not need to use temporary table...

    Thank you very much, it's working
Sign In or Register to comment.