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;
Comments
EG.
CLEAR(Table);
Table.Field := somethinig;
Table.MODIFY;
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
Dean
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.