cancel
Showing results for 
Search instead for 
Did you mean: 

Determine DocNum when my button is clicked on Sales Order

jeff_putnam
Explorer
0 Kudos

I've added a button to the standard Sales Order form and get notified when it's clicked. How do I determine the sales order number (DocNum) from the click event?

private void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)

{

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK)

{ // A mouse click happened. See if it was one of our buttons

if (pVal.ItemUID == "IS_CfgBtn") { // My button was clicked

// Here I need to get the document or DocNum so I can retrieve the document

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

Dear jeff.putnam,

After your button is clicked, just use the following:

SAPbouiCOM.EditText oEditDocNum = (SAPbouiCOM.EditText)form.Items.Item("8").Specific;
var value = oEditDocNum.Value;

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

jeff_putnam
Explorer
0 Kudos

Thank you Ankit! For other novices like me, to get the form specified in Ankit's answer use something like this

// Get the form sending the event 
private SAPbouiCOM.Form oOrderForm;
oOrderForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);