cancel
Showing results for 
Search instead for 
Did you mean: 

Choose from list conditions

Former Member
0 Kudos

I have used the screen painter to create a form which uses a choose from list. It is all working fine but I wish to add conditions to my choose from list so that it doesn't display all the records. I have the SDK sample for choose from list so I can see how I should do it but cannot find which event to hook into to alter the choose from list. I have tried the form load event (before=false) which seems logical to me but the choose from list array is empty when that event is called. I have also tried the before choose from list event but this runs multiple times and I only want to set the conditions once.

I am using the B1DE objects in my addon.

Edited by: Rui Pereira on Dec 23, 2008 3:38 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Plz you can try this code-

I have same problem ,plz check your Formobject name. you change your Form Name

SAPbouiCOM.UserDataSource oUDS_Cod_Ven

formLoad()

{

oUDS_Cod_Ven = (SAPbouiCOM.UserDataSource)oForm_Parameter.DataSources.UserDataSources.Add("oUDS_VCode", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 100);

oEditText = (SAPbouiCOM.EditText)oForm_Parameter.Items.Item("5").Specific;

oEditText.DataBind.SetBound(true, "", "oUDS_VCode");

SAPbouiCOM.Conditions oConditions = null;

SAPbouiCOM.Condition oCondition = null;

oConditions = new SAPbouiCOM.Conditions();

oCondition = oConditions.Add();

oCondition.Alias = "CardType";

oCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;

oCondition.CondVal = "S";

AddChooseFromList(oEditText, "2", "CardCode", false, conditions, SBOAddOn.SBOApplication);

}

protected void AddChooseFromList(SAPbouiCOM.EditText Oedittext, string strObjectType, string strAliasName, bool bIsMultiSelect, SAPbouiCOM.Conditions oConditions, SAPbouiCOM.Application oSBOApplication)

{

SAPbouiCOM.ChooseFromList oCFL;

SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams;

oCFLCreationParams = (SAPbouiCOM.ChooseFromListCreationParams)oSBOApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams);

oCFLCreationParams.MultiSelection = bIsMultiSelect;

oCFLCreationParams.ObjectType = strObjectType;//strObjectType;

string strCLFID = GetChooseFromListID(oSBOApplication);

oCFLCreationParams.UniqueID = strCLFID;

oCFL = oCFLCollection.Add(oCFLCreationParams);

oCFL.SetConditions(oConditions);

Oedittext.ChooseFromListUID = strCLFID;

Oedittext.ChooseFromListAlias = strAliasName;

}

chosefrom list after action

{

if(pval.itemuid=="itemid")

{

string VendorCode = oDataTable.GetValue(0, 0).ToString();

clsUIGeneric.SetUDSValue(oUDS_Cod_Ven, VendorCode);

}

}

Answers (3)

Answers (3)

0 Kudos

try it for C#

var bplID = ((ComboBox)objForm.Items.Item("yourComboBoxName").Specific).Selected.Value;

private static void UpdateChooseFromListBySelectedBranch(Form yourForm, string bplID)

{

var oCfLs = yourForm.ChooseFromLists;

var oConditions = new Conditions();

Condition oCondition = null;

oCondition = oConditions.Add();

oCondition.BracketOpenNum = 1;

oCondition.Alias = "BPLid";

oCondition.Operation = BoConditionOperation.co_EQUAL;

oCondition.CondVal = bplID;

oCondition.BracketCloseNum = 1;

var cfl = oCfLs.Item("yourChooseFromListName");

cfl.SetConditions(oConditions);

Marshal.ReleaseComObject(oCondition);

Marshal.ReleaseComObject(oConditions);

Marshal.ReleaseComObject(oCfLs);

}

Former Member
0 Kudos

Thanks for your answers guys. My problem is where to hook in. I am using B1DE. The menu code looks like:

public class Menu__OCS_MENU_NOMINATIONS : B1XmlFormMenu

{

public Menu__OCS_MENU_NOMINATIONS() {

MenuUID = "OCS_MENU_NOMINATIONS";

this.LoadXml("OCS_NOMREQUESTForm.xml");

}

[B1Listener(BoEventTypes.et_MENU_CLICK, true)]

public virtual bool OnBeforeMenuClick(MenuEvent pVal)

{

this.LoadForm();

return false;

}

}

There is no reference here to the form object that gets created.

The form object looks like:

public class Form__OCS_NOMREQUEST : B1Form {

public Form__OCS_NOMREQUEST() {

FormType = "OCS_NOMREQUEST";

}

[B1Listener(BoEventTypes.et_FORM_LOAD, false)]

public virtual void OnAfterFormLoad(ItemEvent pVal) {

bool ActionSuccess = pVal.ActionSuccess;

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

// ADD YOUR ACTION CODE HERE ...

// Check here reveals that no choose from lists are created yet

}

}

but when I check the choose from lists of the form, they are not there so I assume that they get created some time after the form is loaded. If anybody is working with B1DE objects, where would you add code to interact with the objects on the form after the form is loaded and the objects are created.

Former Member
0 Kudos

Hi Greg,

On Form Load Event(SRF) Add your Bindings ,UId,Alias and all,

For Ex:

.

.

LoadFromXML("Sample.srf")

Dim oCFLs As SAPbouiCOM.ChooseFromListCollection

oCFLs = OForm.ChooseFromLists

Dim oCFL As SAPbouiCOM.ChooseFromList

Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams

oCFLCreationParams = sbo_application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)

oCFLCreationParams.MultiSelection = False

oCFLCreationParams.ObjectType = "ObjecType"

oCFLCreationParams.UniqueID = "CFLId"

oCFL = oCFLs.Add(oCFLCreationParams)

'// Binding

OItem = oForm.Items.Item("EditTextId")

oEdit = OItem.Specific

oEdit.DataBind.SetBound(True, "@ITMM", "U_MItm") '// For Ex

oEdit.ChooseFromListUID = "CFLuid"

oEdit.ChooseFromListAlias = "ItemCode" '// For Ex

'// You can mention the above details simply in SRF Also...

'// Adding Conditions:

'// in item event according to your edit text uid you can add your conditions,

for ex,

If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then

If pVal.ItemUID = "EditTextId" And pVal.FormUID="FormUid" Then

Dim oCons As SAPbouiCOM.Conditions

Dim oCon As SAPbouiCOM.Condition

Dim oCFLs As SAPbouiCOM.ChooseFromListCollection = oForm.ChooseFromLists

oCFL = oCFLs.Item("CFLid")

oCFL.SetConditions(Nothing)

oCons = oForm.ChooseFromLists.Item("CFLid").GetConditions

oCon = oCons.Add()

oCon.Alias = "Aliasid"

oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCon.CondVal = "Conditionvalue" '// Add mulitple conditions here if need then setcondtions

oForm.ChooseFromLists.Item("CFLid").SetConditions(oCons)

End If

End if

'// You can set mulitiple conditions also,

For Ex:

oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND

oCon = oCons.Add()

oCon.Alias = "U_status"

oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCon.CondVal = "Open"

Regards,

Ganesh k