Use existing table to display external info

e1000ie1000i Member Posts: 3
Hi all,

I've been using this forum for a while and always found what I was looking for, but today I need to post a question. I've been doing some googling and so far I haven't found what I'm looking for. I need to populate a lookup form with all the contacts in a user's Skype account (I'm using Skype4COMLib). The client doesn't have a license to create more tables, so I need to reuse some of the existing ones.

I have a Request Form in a report and I need to create a field with a lookup form showing the contacts. What I've done so far is use the table Salesperson/Purchaser (because the fields it has fit quite good with the ones I need) as temporary, insert the values from Skype contacts using an Automation variable and set the OnLookup method of my RF field to show the form. However, all I get is the original Salesperson/Purchaser table, even though I call SETRECORD and SETTABLEVIEW methods before runing the form.

Here is the code:
//UserTable: Salesperson/Purchaser temporary table 
//UserName: Text(50) global variable used as SrcExpression in a Request Form field
//Form: Salesperson/Purchaser form

OnInitReport()
//Fill UserTable with Skype contacts
//[...]

OnLookup(VAR Text : Text[1024];) : Boolean
Form.SETRECORD(UserTable);
Form.SETTABLEVIEW(UserTable);
IF Form.RUNMODAL = ACTION::LookupOK THEN BEGIN
  Form.GETRECORD(UserTable);
  UserName := UserTable.Name;
END;

When debugging, I can confirm that UserTable "has" the values I need. I'm not very used to work with temporary tables so I don't know if I'm missing something. I don't know either if this is the best answer to achieve my goal. Any help will be really appreciated.

BTW, I'm testing on NAV 3.7, but it should work on 5.0 too.

Thanks in advanced

Comments

  • kinekine Member Posts: 12,562
    Set record sets only position, settableview sets only filters. It will never transfer data... But you can use this:
    //UserTable: Salesperson/Purchaser temporary table
    //UserName: Text(50) global variable used as SrcExpression in a Request Form field
    //Form: Salesperson/Purchaser form
    
    OnInitReport()
    //Fill UserTable with Skype contacts
    //[...]
    
    OnLookup(VAR Text : Text[1024];) : Boolean
    IF Form.RUNMODAL(0,UserTable) = ACTION::LookupOK THEN BEGIN
      Text := UserTable.Name;
      Exit(True);
    END else
      Exit(False);
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • e1000ie1000i Member Posts: 3
    Perfect! I thought SETTABLEVIEW transfered the data to the form, good to know it doesn't.

    Thanks for the advice.
Sign In or Register to comment.