Skip to Content
0
Jul 08, 2015 at 02:02 PM

FormEvent won't work

43 Views

Greetings all, I'm writing an addon for SAP B1 9.1 and I'm quite stuck as I don't seem to be able to get FormEvents to work. I need to do something every time the Activity form (FormType 651) is opened, and this code currently does nothing at all neither when I open Activity nor when I try loading records (which should trigger BoEventTypes.et_FORM_DATA_LOAD, but that won't work either). Did I miss something?


using SAPbobsCOM;

using SAPbouiCOM;

using B1WizardBase;


public class Form__651 : B1Form

{

public Form__651()

{

FormType = "651";

}

[B1Listener(BoEventTypes.et_FORM_LOAD, false)]

public virtual void OnAfterFormLoad(BusinessObjectInfo pVal)

{

bool ActionSuccess = pVal.ActionSuccess;

Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);


Connection.SBO_Appln.MessageBox("Hello");


//form.Items.Item("51").Visible = false;

}

}


The main is like this:

public static void Main()

{

try

{

if (!Connection.Connect()) return;

PROJECTNAME_Db addOnDb = new PROJECTNAME_Db();

addOnDb.Add(Connection.oCompany);

PROJECTNAME_Cockpits addOnCockpit = new PROJECTNAME_Cockpits();

addOnCockpit.Manage(Connection.SBO_Appln, Connection.oCompany);

Connection.SBO_Appln.MessageBox("Hello");

System.Windows.Forms.Application.Run();

}

catch (System.Runtime.InteropServices.COMException com_err)

{

System.Windows.Forms.MessageBox.Show("ERROR - Connection failed: " + com_err.Message);

}

}


By the way, the whole addon loads alright and rightly keeps running until I stop the debugger. Thanks in advance!