cancel
Showing results for 
Search instead for 
Did you mean: 

Choose From List Event

Former Member
0 Kudos

Dear Experts,

How can I use the choose from list in my user defined form ? Please explain in detail. I am very new to SDK.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Although there are many threads regarding this Choose From List event but still I am providing you following piece of code. You can try this as follows:

On BeforeAction = false

SAPbouiCOM.ChooseFromListEvent cflevent = (SAPbouiCOM.ChooseFromListEvent)pVal;

SAPbouiCOM.ChooseFromList oCFLEvento = default(SAPbouiCOM.ChooseFromList);

string strUid = cflevent.ChooseFromListUID;

oCFLEvento = this.m_SBO_Form.ChooseFromLists.Item(strUid);

SAPbouiCOM.DataTable oDataTable = cflevent.SelectedObjects;

                                   

                                    if (oDataTable == null)

                                    {

                                        return;

                                    }

                                    if (pVal.ItemUID == enControlName.BranchCode && strUid == "CFL_2" && pVal.FormMode != Convert.ToInt32(BoFormMode.fm_FIND_MODE))

                                    {

                                        string ProjectCode = oDataTable.GetValue("PrjCode", 0).ToString();

                                        string ProjectName = oDataTable.GetValue("PrjName", 0).ToString();

                                        this.oDataSource = (DBDataSource)m_SBO_Form.DataSources.DBDataSources.Add("@DMRMASTER");

                                        this.oDataSource.SetValue("U_CBrnch", 0, "");

                                        this.oDataSource.SetValue("U_NBrnch", 0, "");

                                        this.oDataSource.SetValue("U_CBrnch", 0, Conversions.ToString(ProjectCode));

                                        this.oDataSource.SetValue("U_NBrnch", 0, Conversions.ToString(ProjectName));

                                    }

Hope I am pretty clear.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

Hi,

Can you please explain what your code is doing here. ? And what these lines specify that you have written in your code ? Also please explain how to add a CFL to user defined form.?

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Here is the code with detailed explanation:

SAPbouiCOM.ChooseFromListEvent cflevent = (SAPbouiCOM.ChooseFromListEvent)pVal;


// Above written line Contains information about the current choose from list event, which is an ItemEvent event of type et_CHOOSE_FROM_LIST. To access this object, cast the ItemEvent object into this object.

                                    SAPbouiCOM.ChooseFromList oCFLEvento = default(SAPbouiCOM.ChooseFromList);


//The ChooseFromList object enables to set the display of the Choose From List for a specified object.

                                    string strUid = cflevent.ChooseFromListUID;

                                    oCFLEvento = this.m_SBO_Form.ChooseFromLists.Item(strUid);

                                    SAPbouiCOM.DataTable oDataTable = cflevent.SelectedObjects;

//Above line described The items selected in the ChooseFromList form.

                                   

                                    if (oDataTable == null)

                                    {

                                        return;

                                    }

                                    if (pVal.ItemUID == enControlName.BranchCode && strUid == "CFL_2" && pVal.FormMode != Convert.ToInt32(BoFormMode.fm_FIND_MODE))

                                    {

                                        string ProjectCode = oDataTable.GetValue("PrjCode", 0).ToString();

                                        string ProjectName = oDataTable.GetValue("PrjName", 0).ToString();

                                        this.oDataSource = (DBDataSource)m_SBO_Form.DataSources.DBDataSources.Add("@DMRMASTER");

                                        this.oDataSource.SetValue("U_CBrnch", 0, "");

                                        this.oDataSource.SetValue("U_NBrnch", 0, "");

                                        this.oDataSource.SetValue("U_CBrnch", 0, Conversions.ToString(ProjectCode));

                                        this.oDataSource.SetValue("U_NBrnch", 0, Conversions.ToString(ProjectName));

                                    }

The Rest is explained by

that how can you attach CFL to your form.

Hope it is helpful.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

Hi,

I have 2- 3 more doubts.

1. this.oDataSource = (DBDataSource)m_SBO_Form.DataSources.DBDataSources.Add("@DMRMASTER"); //What this line will do in code.

2. When I am trying to add CFL in matrix column and previewing the form I am not able to see the CFL.

3. What is DBDataSource used for ?

please reply.

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dhiraj,

Below are the answers to your questions:

1. DBDataSource Represents a SAP Business One database table to be attached to a form. So in that line I am adding a DBDataSource to DMRMASTER Table.

2. Yes you cannot see a CFL in preview mode because there is no row in the matrix while you are previewing it.

3. DBDataSource contains the datasource element i.e. the Tables.

Hope it is helpful.

Regards

Former Member
0 Kudos

Hi,

Still I have doubt about but one more thing is it the standard method for using Choose From List Event.

please reply.

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dhiraj,

If you have still any doubt you may check following thread:

http://scn.sap.com/thread/3460290

Besides this, I am not sure whether it is standard or not but as it is provided in SAP B1 SDK Help Files also, so I use it like that only. And some of my friends in my circle also use the choose from list event like this.

If still problem not solved, then you can use it in simple way like this:

if (pVal.ItemUID == enControlName.Matrix && strUid == "CFL_2" && pVal.ColUID == enControlName.PartyCode)

                                    {

                                        SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)m_SBO_Form.Items.Item(enControlName.Matrix).Specific;

                                        string CardCode = oDataTable.GetValue("CardCode", 0).ToString();

                                        string CardName = oDataTable.GetValue("CardName", 0).ToString();

                                        int Row = pVal.Row;

// pVal.Row will give you the currently active row.

                                        try

                                        {

                                            SAPbouiCOM.EditText oEditCardCode = (SAPbouiCOM.EditText)oMatrix.Columns.Item(enControlName.PartyCode).Cells.Item(Row).Specific;

                                            oEditCardCode.Value = CardCode;

                                        }

                                        catch (Exception ex)

                                        {

                                            Program.oMainSAPDI.ShowMessage(ex.Message, BoStatusBarMessageType.smt_None);

                                        }

                                        finally

                                        {

                                            SAPbouiCOM.EditText oEditCardName = (SAPbouiCOM.EditText)oMatrix.Columns.Item(enControlName.PartyName).Cells.Item(Row).Specific;

                                            oEditCardName.Value = CardName;                                           

                                        }

                                    }

Hope it is helpful.

Thanks & Regards

Ankit Chauhan

Former Member
0 Kudos

Hi,

Thanks for your kind support.

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dhiraj,

Once the problem is solved, please close the thread by marking correct answer.

Thanks & Regards

Ankit Chauhan

Answers (2)

Answers (2)

Former Member
0 Kudos

hi dhiraj

try this code for choose from list

                SAPbouiCOM.ChooseFromListCollection oCFLs = null;

                SAPbouiCOM.Conditions oCons = null;

                SAPbouiCOM.Condition oCon = null;

                oCFLs = oForm.ChooseFromLists;

                SAPbouiCOM.ChooseFromList oCFL = null;

                SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams = null;

                oCFLCreationParams = ((SAPbouiCOM.ChooseFromListCreationParams)(ClsSBOAddOn.SBOApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)));

                oCFLCreationParams.MultiSelection = false;

                oCFLCreationParams.ObjectType = "2";

                oCFLCreationParams.UniqueID = "CFL_2";

                oCFL = oCFLs.Add(oCFLCreationParams);

                oCons = oCFL.GetConditions();

                oCon = oCons.Add();

                oCon.Alias = "CardType";

                oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;

                oCon.CondVal = "C";

                oCFL.SetConditions(oCons);

                oCFLCreationParams.UniqueID = "CFL2";

                oCFL = oCFLs.Add(oCFLCreationParams);

            }

            catch (Exception ex)

            {

                ClsSBOAddOn.SBOApplication.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);

            }

Former Member
0 Kudos

hi.

First  you have to decide on which table  you want to  create cfl ok..

you have to get  object id  for the  system from.

like item master  2

bp master  4

emp master  171

these are the  ids given by  sapb1  default........

http://scn.sap.com/thread/3350614

for your reference  i had post above post you can get all the  object ids..

Former Member
0 Kudos

have a look on above  from......................

on which  field you want to put  cfl

you have  to bind it first  with data base ok

means

alias  is compulsarily.........

tablename is compulsarily.......

choosefromlistalias is  compulsarily.......

choosefromlistuid is compulsarily.......

next step............

in screen painter  go to  collection tab  and then you have to create  new cfl  with respective to the  cfl  .

i want to create  cfl  for  emp master so i enter  171  object id.

There is one example is available in samples for cfl..

C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\17.ChooseFromList

plz check it............