create user id who created sales order

hai there, how about to track who was create the sales order?

i develop for sales order form like this

form - onModifyRecord()

SalesHeader.INIT;
SalesHeader.GET(“Document Type”,“No.”);
SalesHeader.“Login ID” := USERID;
SalesHeader.MODIFY;

but i failed

what did i miss?

if i made command button and i put that code onPush

it will be succeed… my question is which trigger must i put that code?

This needs to be done on the table. NEVER put business logic on forms.

In any case, you will need your NSC to do this. It requires access to code.

it’s the same

i put the code onModify()

at table sales header

and it still doesn’t work… :frowning:

Try this:

OnInsert

“Login ID” := USERID;

onInsert is done :slight_smile: thanx Davis

but while on modify it doesn’t work

IF WebSite.FIND(’-’) THEN
SynchMgt.ModifySalesHeader(Rec,xRec);
“Login ID” := USERID;

i already try add SalesHeader.get;

but it failed

Stan make up your mind, you want to know who created the record, or who modified the record.

PS its David by the way [;)]

hehehe

first it sales order haven’t been created i want to know who is created

let’s say Sales Order number 001, create by David

so the login id is David

after that for example is modified by Stan

so the sales order login id is Stan

Ok, so its somethign completely different. Take a look at how its done on the Item card, that is exactly what you want, i.e. “last modified by” just make it the same as “Last modified on”

You could always use the change log

Too obvious! And - remember - problems with the “2nd” license and the change log.

Why to use something already there if we can do it by ourself with a poorer result? It’s Friday today?

thank you very much David

now it could done like i want it :slight_smile:

Hey Stan,

I know Davis, sorry David, [:$], has told you how to achieve what you want, but! I think your logical understanding of Navision Development in this instance needs some help.

so your code

SalesHeader.INIT;
SalesHeader.GET(“Document Type”,“No.”);
SalesHeader.“Login ID” := USERID;
SalesHeader.MODIFY;

The first thing to note, is that you have created an unnecessary variable in this instance. You have created an instance of Sales Header record. But the thing to bear in mind with your code being on the “OnModfyRecord” trigger of the Sales Order form, is that the Pointer is on the record you wish to edit anyway. So to acheive what you wanted you would simply needed to have put

Next if your use of Init. Whilst this clears the record as need (and sets the defaults), it is also basically “Creating a record” with default values that has not been commited to the database (Which occurs on the call of Insert).

The normal call here would be reset.

But as explained by David on here you should be using the Table for this. The reason?, well, for each table you can have a multitude of forms, the Sales Header being a prime example, you have the Quote, Order, and Invoice forms just as an example. If you modify the form then you need to modify all other forms that are bound to that table. But it is highly unliekly that you will have two tables with the same data. And if you do your design is usually flawed and you need to go through the Database Normalisation process.

But again, if you are using the triggers on the Table then you need to undertstand that the “Pointer” is at the record calling the trigger, you do not need to go and get the record, and then modify it. There are instances when you do, but in the two examples above the pointer will be where you need it.

Any questions let me know.

/TH

ok then Tony

my problem is answered … thanks to David and all of you :slight_smile: