cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One SDK - LoadFromDataSource(), FlushToDataSource(), how to store data back to UDT?

Peach14
Explorer
0 Kudos
123

I've created my own User-defined table and use it in my editable matrix sending data back and forth to DBDataSource with LoadFromDataSource() and FlushToDataSource()

The question is, to store data, including insert, update and delete, back to UDT, do I need to manually loop over rows in the matrix, then run .Update(), .Add() or .Remove() myself or is there a way to manage it automatically?

I'm stuck at FlushToDataSource() after clicked on a Update button and ChatGPT taught me to manually set the data back, but I don't think it's an efficient way and tried to find other ways in UI and DI manual but not found anything.

Here is my code

if (pVal.ItemUID == "1" && pVal.FormMode == (int)SAPbouiCOM.BoFormMode.fm_UPDATE_MODE && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == true)
{
    SAPbouiCOM.Form oForm = oApp.Forms.Item(pVal.FormUID);
    SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("matrix").Specific;
                        
    oMatrix.FlushToDataSource();

    SAPbouiCOM.DBDataSource oDBDataSource = oForm.DataSources.DBDataSources.Item("@myUDT");
                        
    ...here is where I'm stuck.

}

 

View Entire Topic
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi Peach14,

You can register the User Defined Object (UDO) for your user form.

After that system automatically handles Add, Update, Remove operations.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Peach14
Explorer
0 Kudos
Thank you!
Peach14
Explorer
0 Kudos
Can I bind this to my own custom form? Or I need to use system created UDO form.