on 01-07-2014 4:12 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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));
}
that how can you attach CFL to your form.
Hope it is helpful.
Thanks & Regards
Ankit Chauhan
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
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
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
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);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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............
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.