I've written some code to query the ODATA endpoint in Dynamics Nav 2016. I did this by creating an ODATA connected service. I wrote the following code to add a record:
var navision = new Navision(
new Uri("http://navision:7048/navision/OData/Company('Company1')"))
{
Credentials = new NetworkCredential("MyUser@example.com", "password")
};
navision.AddToFoo(new Foo() { Name = "Bar" });
navision.SaveChangesAsync();
I have enabled 'Change Log Entries' for the Foo
table. However, when the above code executes, the user displayed in the change log entries is MyUser@example.com
. Is it possible to set this user myself explicitly?
There is no standard way to do this kind of substitution. Change log entry is created as follows. USERID
is system function that will return logged in user name.
ChangeLogEntry."User ID" := USERID;
If you can have a development on your system then you need to change navision.AddToFoo(new Foo() { Name = "Bar" });
to something like navision.AddToFoo(new Foo() { Name = "Bar", ChangedBy = "RealUserName"});
and have this field added to table Foo. This will at least allow you to see last user that changed the record.