Hi All,
Can somebody explain the use of write method at table level.
Regards,
Nunna
*This post is locked for comments
Hi All,
Can somebody explain the use of write method at table level.
Regards,
Nunna
*This post is locked for comments
I think I can explain where some of the confusion is coming from.
As stated by others, the 'Write' method on a table will call either insert or update on table, depending on whether the record already has a RecId or not. That I think is fine, and not where the true question resides.
I think what is important to note is that unlike the 'write' method on a Form Datasource, the 'write' method on a table does NOT get called by the system when the record is saved.
So, to say it again, when a user saves a record on a form, the system will call the 'write' method on the Datasource. And that method will ultimately call either the 'insert' or 'update' method on the table, depending on whether the record is a new record or not. But, the write method on the table will NOT be called.
This I think is a bit confusing and different than some other methods. For example, if you have some additional validation logic, you could put the code in either the 'validateWrite' on the Datasource or the 'validateWrite' on the table. Both are called by the system. However, when it comes to the 'write' method, only the Datasource write method is called, and NOT the table 'write' method.
It would seem that the 'write' method on the table gets called when it is explicitly called through code, and can be useful for this purpose. But it does not seem to be called by forms. (Please correct me if I am mistaken).
Most of the time when a developer is writing their code, they know whether the record exists or not, so they will either call 'update' or 'insert' directly. They typically would not call the 'write' method on a table. Therefore, if you have logic that needs to run when a record is saved, it probably makes sense to create a new method to store this logic. But then call this logic from both the 'update' and the 'insert' method. While you could put it in the 'write' method, there is a chance it won't get called if another developer doesn't know it is there and just calls 'update' or 'insert' directly. Which is common to do.
Write method is used on forms data source to insert or update records to database. The difference is that write calls validatewrite method. Insert method being on the table inserts records into the table. So, in form use Write and in tables use Insert.
Arun Sharma
Thanks Sohaib for sharing information.
Regards,
Nunna
read and search about sequence of executions
Thanks Martin for sharing information.
Regards,
Nunna
Hi Sohalib,
Even I too agree with marin, Since it is there in Documentation.
But Form data source write() method is hitting, then what might be the debugger issue to not hit in table write method.,
And also I have written info statement in table write method, I didn't info message as well while update/insert. So it's clear that table write() method will not while insetting or updating record, and I just want to know when this method will get execute.
write() calls insert() or update(), not the other way around.
there can be other reasons if debugger is not going there inside.
what martin told you, is correct.
msdn.microsoft.com/.../aa569665.aspx
blaming write() method for 'Debugger not working' is not correct.
Hello,
DMF imports are using it, also thats why DMF is missing validations
Yes it stated same,
But if I keep the break point in that method, it's not hitting while inserting/ updating.
Hence I assume, this method will not hit while insert/ update, Can you tell me why debugger is not hitting
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156