cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 SDK How to Get Selected Row of a Matrix

former_member183373
Active Participant
0 Kudos

Hello Everyone,

I am working on the "Batches - Setup" form of SAP Business One. And I need to get the selected row of the matrix in the form. I can call the matrix and get any value in its cells but I want to get the index number of the row that is currently selected by the user. I couldn't find anything useful in the SDK Help File. I know that "SAPbouiCOM" has classes like "SelectedRows" but I don't know how to proceed.

Could you please show me a method that would be helpful.

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

maik_delly
Active Contributor
0 Kudos

Hi Atilla,

I guess you are talking about the Batch Management form  ( formtype = 65271 ) ?!

You could simply catch any event on the form. E.g. click on cancel in ItemEvent :


if (pVal.BeforeAction && pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK && pVal.FormTypeEx == "65271" && pVal.ItemUID == "2")

{

    BubbleEvent = false;

    SAPbouiCOM.Form oForm = SBO_Application.Forms.Item(FormUID);

    SAPbouiCOM.Matrix oMatrix1 = (SAPbouiCOM.Matrix)oForm.Items.Item("35").Specific;//Rows from Document

    int selrow1 = oMatrix1.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_RowOrder);

    SAPbouiCOM.Matrix oMatrix2 = (SAPbouiCOM.Matrix)oForm.Items.Item("3").Specific;//Created Batches

    int selrow2 = oMatrix2.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_RowOrder);

    String result = selrow1 != -1 ? "Selected rows from 1st Matrix: " + selrow1 + "\r\n" : "No row selected in 1st Matrix\r\n";

    result += selrow2 != -1 ? "Selected rows from 2nd Matrix: " + selrow2 : "No row selected in 2nd Matrix";

    SBO_Application.MessageBox(result);

}

GetNextSelectedRow will return -1 if no row is selected.

regards,

Maik

former_member183373
Active Participant
0 Kudos

Hi Maik,

Thank you very much for your help. That was definitely what I need. GetNextSelectedRow method works correctly.

Answers (0)