I created modified field in inventtablemodule, the purpose is if I change a value in a field, it will update a field in BOM table. However, the data display in form not display the real data that already change in inventtablemodule. But when I debug, after finish debug, the field value can change. But if i am not doing debug, the value not show the real time data in the form of BOM as datasource.
public void modifiedField(fieldId _fieldId)
{
super(_fieldId);
if(this.isFormDataSource())
{
switch(_fieldId)
{
case fieldnum(InventTableModule,UnitId):
this.PopulateInventUnit();
this.updateBOMID();
break;
}
}
}---------------------
void updateBOMID()
{
BOM tblBOM;
InventItemInventSetup inventItemInventSetup;
inventDimId inventDimBlank;
InventTableModule inventTableModule,inventTableModule2,inventTableModule3;
InventTable inventTBL;
str id,id2,id3;
;
if(this.UnitId!='STOP')
{
ttsbegin;
select forupdate tblBOM
where tblBOM.ItemId == this.ItemId ;
{
Select inventTableModule
where inventTableModule.ModuleType == ModuleInventPurchSales::Invent && inventTableModule.ItemId == this.ItemId;
{
tblBOM.UnitId = inventTableModule.UnitId;
tblBOM.doupdate();
}
}
ttscommit;
}
}
Can anyone help me.Thanks
*This post is locked for comments
First of all, never update data in DB on modified field. User should be able to click Esc and cancel changes he did, how is it going to work in your case? So it's better to move you code to record save.
Talking about refresh issue, you need to call reread() and refresh() on the datasource to get updated data from the DB after you updated it, like:
formDataSource.reread()
formDataSource.refresh()
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156