cancel
Showing results for 
Search instead for 
Did you mean: 

Form - Bad Value

Former Member
0 Kudos

To return the value of a CFL and try moving to an Edit Box with the error 'Form - Bad Value'

Anyone have a suggestion?

Code:

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST && !pVal.Before_Action)

{

       oForm = SBO_Application.Forms.Item(pVal.FormUID);

       oForm.Select();

       IChooseFromListEvent ichoose = (IChooseFromListEvent)pVal;

        if (ichoose.ChooseFromListUID == "CFL_52")

        {

                oEdit = (EditText)oForm.Items.Item("Item_4").Specific;

                oEdit.Value = ichoose.SelectedObjects.GetValue("ItmsGrpNam", 0).ToString();

        }

}

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Lucas,

Can you please what choosefromlistalias you have assigned to this object , is it same as you are selecting i.e.  Is the choose from list alias is "ItmsGrpNam"

Regards

edy_simon
Active Contributor
0 Kudos

Hi Lucas,

When handling choose from list, whenever you can, always set the value to the datasource.

If you set the value to the item object, you will get error.

And also, make sure your DataSource can hold the ItmsGrpNam value (ie. Alphanumeric(50))

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST && !pVal.Before_Action)

{

       oForm = SBO_Application.Forms.Item(pVal.FormUID);

       oForm.Select();

       IChooseFromListEvent ichoose = (IChooseFromListEvent)pVal;

        if (ichoose.ChooseFromListUID == "CFL_52")

        {

                //oEdit = (EditText)oForm.Items.Item("Item_4").Specific;

                //oEdit.Value = ichoose.SelectedObjects.GetValue("ItmsGrpNam", 0).ToString();

               oUDS = ichoose.SelectedObjects.GetValue("ItmsGrpNam", 0).ToString();     //oUDS is the underlying datasource object oh oEdit.

        }

}

Regards
Edy

Former Member
0 Kudos

Hello Lucas,

You are using UDO?

Try this:

SAPbouiCOM.IChooseFromListEvent oCFLEvento = null;

string sCFL_ID = null;

SAPbouiCOM.Form oForm = null;

SAPbouiCOM.ChooseFromList oCFL = null;

oCFLEvento = ((SAPbouiCOM.IChooseFromListEvent)(pVal));

sCFL_ID = oCFLEvento.ChooseFromListUID;

oForm = objApplication.Forms.Item(FormUID);

oCFL = oForm.ChooseFromLists.Item(sCFL_ID);

if (oCFLEvento.BeforeAction == false)

{

    SAPbouiCOM.DataTable oDataTable = null;

    oDataTable = oCFLEvento.SelectedObjects;

    string val = null;

    try

    {

        val = System.Convert.ToString(oDataTable.GetValue(0, 0));

    }

    catch (Exception ex)

    {

        objApplication.MessageBox(ex.Message, 1, "Ok", "", "");

    }

    oEdit = (EditText)oForm.Items.Item("Item_4").Specific;

    oEdit.Value = val;

}