Button et_CHOOSE_FROM_LIST event

Eric Lapouge

Hi,

In a custom extension I'm in need to handle the standard et_CHOOSE_FROM_LIST event, fired from a button (defined as a bitmap button and with the ChooseFromListID set to an existing (object type 2, but not relevant to the question) CFL).

I need the standard CFL dialog, since the user will use the standards Sort and Filter sub-dialogs in its searches.

How may I do it with the framework?

Regards,

Eric

Anders Olsson

Hi Eric,

Below is a code example of how to use the ChooseFromList. txtCustomer is a TextEdit that will be populated with the user's choice.
By adding a handler for the ChooseFromListEvent event, you can also pull out the description.


void buttonClicked(SwissAddonFramework.UI.EventHandling.ItemEvents.Click e)
{
SwissAddonFramework.UI.Dialogs.ChooseFromList cflTextEdit = new SwissAddonFramework.UI.Dialogs.ChooseFromList(new SwissAddonFramework.UI.Dialogs.ChooseFromList.DefaultSQLQuery("SELECT CardCode, CardName FROM OCRD"), "CardCode", true, true, txtCustomer);
cflTextEdit.Title = "List of Business Partners";
cflTextEdit.ChooseFromListEvent += new SwissAddonFramework.UI.Dialogs.ChooseFromList.ChooseFromListHandler(cflTextEdit_ChooseFromListEvent);
}

void cflTextEdit_ChooseFromListEvent(SwissAddonFramework.UI.Dialogs.ChooseFromListEvent e)
{
string customerName = string.Empty;

if (e.Results.Count > 0)
{
e.Results[0].TryGetValue("CardName", out customerName);
}

// Do something with customerName
}


Regards,
Anders

Eric Lapouge

Hi Anders,

My full need is the following one:
Display a form with misc. fields and a grid. The fields, are used to filter the content of the grid, and one of its columns is a combobox which displays a list of BP. It's to fill this combo that I'm in need of a CFL.

The CFL (multi-selection) has to display customers only and the user must be able to filter the list displayed, since the result will fill the combobox.

I can't decide any criteria used to fill the CFL: the user want to filter on any data from the BP.

For all these reasons, I can't use the CFL provided by the framework and have to use the standard one.

My only problem, is that the framework don't handle the ET_CHOOSE_FROM_LIST event, which is triggered by the SDK, so I can't change its conditions object...

So, I need a way to handle this event either internaly by the framework (so in a next version...) either directly from my code.

Hope to have been clearier...

Regards,

Eric

Anders Olsson

Hi Eric,

I'm sorry for my late reply, but here goes:

When developing using the framework, you have access to the SAP APIs providing that you reference the wrapper dlls SAPbobsCOM.dll and SAPbouiCOM.dll that come with the coresuite framework.

Using the UI API directly you can catch any UI event you want.

In the code sample below, I create a form with a button that when clicked executes a "SAP" ChooseFromList.

The CFL code is taken from the SDK sample 17.ChooseFromList.


public void Execute()
{
// Get the application object
SAPbouiCOM.Application application = SwissAddonFramework.B1Connector.GetB1Connector().Application;

// Create the form
SwissAddonFramework.UI.Components.Form form = SwissAddonFramework.UI.Components.Form.CreateNewForm("myFormType", "FORM01");

// Add a button
SwissAddonFramework.UI.Components.Button button = SwissAddonFramework.UI.Components.Button.CreateNew("myButton");

form.AddItem(button);

// Load the form into SAP
form.Load();

// Get the SAPbouiCOM form
SAPbouiCOM.Form oForm = application.Forms.GetForm("myFormType", 0);

// Create the ChooseFromList
SAPbouiCOM.ChooseFromListCollection oCFLs = oForm.ChooseFromLists;

SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams = (SAPbouiCOM.ChooseFromListCreationParams)SwissAddonFramework.B1Connector.GetB1Connector().Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams);
oCFLCreationParams.MultiSelection = false;
oCFLCreationParams.ObjectType = "2"; // Business Partners
oCFLCreationParams.UniqueID = "CFL1";

SAPbouiCOM.ChooseFromList oCFL = oCFLs.Add(oCFLCreationParams);
SAPbouiCOM.Conditions oCons = oCFL.GetConditions();

SAPbouiCOM.Condition oCon = oCons.Add();
oCon.Alias = "CardType";
oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
oCon.CondVal = "C";

oCFL.SetConditions(oCons);

// Attach the button to the CFL
button.ChooseFromListUID = "CFL1";

application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(application_ItemEvent);
}

private void application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
{
BubbleEvent = true;

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST && pVal.BeforeAction == false)
{
SAPbouiCOM.IChooseFromListEvent oCFLEvento = ((SAPbouiCOM.IChooseFromListEvent)(pVal));
SAPbouiCOM.DataTable dt = oCFLEvento.SelectedObjects;

// Check the datatable for selected items
}
}


Regards,
Anders

Eric Lapouge

Hi Anders,

Thanks for your answer... It's what I did, to be able to finish my work for my customer.

What I dislike from this solution, is that it's breaking the rule of using the framework for event handling and that my development isn't isolated anymore from the variation of the SDK.

Regards,

Eric
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post