How to build a tree view form ?

Bronko
Bronko Member Posts: 6
Hi,

I´m still looking for a way to create a tree view form with standard NAV resources.
For example : I want to show a nested production BOM with expand / collapse function.
There are several forms in NAV 5.0 (583, 634, 703, 5522, 5847, 6520) that already have
the behavior I need, but the problem is, that they are based on a temporary table.
So the changes won't be written back to the database. I tried to synchronize the changes
by code, but there's a problem with the OnModify :
  LocalRec := Rec;
  LocalRec.MODIFY;
After entering the second modification I get the message 'Another user has modified the record...'.
In Form 5522 it seems to work somehow, but I couldn't figure out how.

How is it possible to build a tree view form and write back the changes to the database ?

Comments

  • David_Singleton
    David_Singleton Member Posts: 5,479
    You need to have code something like:

    MyProdBomLine.get(rec."no.","line no.");
    Myprodbomline := rec;
    MyProdbomline.modify;

    (There are many different ways to format this, so play around till you get the ideal).
    David Singleton
  • Bronko
    Bronko Member Posts: 6
    Hi David,

    thank you for your answer.

    Unfortunately this doesn't work. I get the same error after the second modification. I also tried with TRANDFERFIELDS, but still the same problem.
  • David_Singleton
    David_Singleton Member Posts: 5,479
    Bronko wrote:
    Hi David,

    thank you for your answer.

    Unfortunately this doesn't work. I get the same error after the second modification. I also tried with TRANDFERFIELDS, but still the same problem.

    Show the actual code.
    David Singleton
  • Bronko
    Bronko Member Posts: 6
    Form - OnModifyRecord() : Boolean
    
    ltRec.GET("Line No.");
    ltRec := Rec;
    ltRec.MODIFY;
    
  • David_Singleton
    David_Singleton Member Posts: 5,479
    Bronko wrote:
    Form - OnModifyRecord() : Boolean
    
    ltRec.GET("Line No.");
    ltRec := Rec;
    ltRec.MODIFY;
    

    #-o sorry, my bad.... try
    Form - OnModifyRecord() : Boolean
    
    ltRec.GET("Line No.");
    ltRec.transferfields(Rec);
    ltRec.MODIFY;
    
    David Singleton
  • Bronko
    Bronko Member Posts: 6
    I'm sorry, but I still get the same error message.
  • Bronko
    Bronko Member Posts: 6
    I solved the problem :
    LocalRec := Rec;
    LocalRec.MODIFY;
    Rec := LocalRec
    

    The MODIFY generates a new version of the record and you have to reassign it to the actual record to be able to make further changes.