Announcements
Hello,
I have attached a new button in the ProdTableListPage's action Pane. I need to write a clicked method to stop any active jobs on the selected production record.
I only find a Command property for that button but I dont know where exacly is that method supposed to be modified/coded?
Thanks a lot before hand for your kind help
RecVersion is always changed when you update a record. It does not matter which field(s) in the record were changed.
If you don't get such error, it only means that your process is not trying to update a record using an outdated RecVersion.
Perfect explanation Nikolaos,
In the case of updating the record but at a new custom field, this RecVersion is not changed?. is that correct?.
because at first time just by updating my custom NoYes field in the production table did not received any error of "The values displayed in the form are not current"
It's needed so that the form will get an up-to-date record (that your code manipulated).
If the record is not up to date, you will get an error if you try to update something on the form (like you noticed).
This mechanism exists to prevent users and processes from accidentally overwriting each other's changes in the records.
Here's how it works:
1) When open the form, records are loaded from the database and stored in the client. Each record contains RecVersion field.
2) While the form is open, your button changes a record. This update changes RecVersion of the record in the database
3) Now if you try to change the same record on the form, the client notices that RecVersion of the record that is being saved, and RecVersion in the database are not the same. This means that someone else changed the record, and if your save would be succesful it would overwrite those changes. Even if you change only field A, actually the whole record with all field values is always saved, so if any other field was changed by that other process, those changes would disappear when you save your (outdated) record.
4) With refresh/research, latest version is fetched from the database, and you are now working with the latest version
tried with :
FormControl _fc;
_fc = _args.callerFormControl();
_fc.dataSourceObject().refresh();
_fc.dataSourceObject().research(true);
unthough I don't know excalcly why is must to do that is working perfect :)
Thanks a lot Nikolaos thanks a lot for your help!
Try _args.record().dataSource().
My code is on the class called by the MenuItem as you said I have access only to Main (Args _args)
how do i get to the formDataSource?
I know I ask to much but I am very close to finish . appreciated with your help
After running your logic, you should refresh the form data source by calling [formDataSource].refresh() followed by [formDataSource].research(true).
Hi Nikolaos,
1) I managed to follow your suggestions. At first time when clicking the button it updates the custom field and also in the list page automatically. this part is ok so far.
2) Now I have used the JmgJobBundle class to stop any active jobs from the production selected when button is clicked. This is also doing ok. but when I try updating the field again in 1)
throws an error that says: Cannot edit a record in Production orders (ProdTable).
The values displayed in the form are not current, so an update or deletion cannot be made. To view the current values, on the Command menu, click Restore or press CTRL+F5.
part of the code inspired by \Clases\JmgTermCloseOpenregTrans . createStopRegisterationJob()
1) Update_recordset is not making much sense since you update only one record (since RecId is unique in each table).
You will always need a transaction (ttsbegin/ttscommit) if you update data. No matter if you use update_recordset or not.
2) Check ProdTableListPageInteraction\setButtonAccess
Hi Nikolaos,
I have followed your recomendation. I added the a menuItemButton and managed to code the basis of what I need ( update the custom NoYes record after button clicked)
1) I wonder if this code is according to the best practices or I need to improve a little bit ( used the Update_recorset instead of ttsbegin/ttscommit)
2) How do I call the Button control, so I can disable the button after update?
André Arnaud de Cal...
294,206
Super User 2025 Season 1
Martin Dráb
232,968
Most Valuable Professional
nmaenpaa
101,158
Moderator