Updating tables/fields not associated with a form

david.weeksdavid.weeks Member Posts: 96
edited 2004-02-25 in Navision Attain
Hello All,

What approach should I take to update a field on a table that is not associated with the form I am using?

i.e. When pressing a button on my form, I want to update various fields in other tables within Navision.

Any ideas?

Thanks

Comments

  • wonmowonmo Member Posts: 139
    create a record type variable of the table that you want to update and insert code on the OnPush trigger:

    EG.

    CLEAR(Table);

    Table.Field := somethinig;
    Table.MODIFY;
  • Dean_AxonDean_Axon Member Posts: 193
    Personally I create a function so I can place all commands in one place.

    you need to declare a variable of type record and the table number of the table you wish to update.

    You must then tell the system which record in the table you want to update. there are many ways to acheive this but the simpliest is to use the get command. This however relies on you having all the fields that are used in the primary key.
    so, Lets say you wanted to update the customer record with a name change from a sales order:

    Create a variable:
    Name Datatype (cant remember last title)
    Cust Rec Customer (table 18 )

    based on using a button, on the "on push ()" trigger you would put the following:
    Cust.get("Sell-to customer no.");
    Cust."name":="Sell-to Customer name";
    Cust.Modify;

    If you do not have all the data required for the key fields, i.e. the sales line table then you would have to do something like this:

    Create a variable:
    Name Datatype (still cant remember last title)
    SalesLine Rec sales Line (table 37 )

    based on using a button, on the "on push ()" trigger you would put the following:
    SalesLine.Setrange("Document type","document type"::Order;
    SalesLine.Setrange("Document No.","No.");
    if SalesLine.find('-') //tells the system to use the first match found
    OR
    if SalesLine.find('+') //uses the last line found
    then
    Salesline."somefield":="SomeUpdatefield";
    SalesLine.Modify;

    It then gets a bit more complex when you want to amend ALL lines found that match the filters so it would look something like this:

    SalesLine.Setrange("Document type","document type"::Order;
    SalesLine.Setrange("Document No.","No.");
    if SalesLine.find('-') then
    repeat
    Salesline."somefield":="SomeUpdatefield";
    SalesLine.Modify;
    until salesLines.next=0;

    Hope this helps explain things a little :D

    Dean
    Remember: Keep it simple
  • david.weeksdavid.weeks Member Posts: 96
    Hello All

    Yes, this certainly helps and I have already had some sucess with doing what I require.

    Dean - Thanks for your post, this will be most beneficial.
Sign In or Register to comment.