Skip to Content
2

How to enable green buttons in sap business one User created form

Jul 04, 2017 at 11:04 AM

607

avatar image
Former Member

How to enable First Data Record, Previous Record, Next Record, Last Data Record and Find record Menu options in SAP Business One , With User Created Form.

Normally System defined forms above options are enabled automatically, but while form is created by User it self Green arrows(above options) are disable mode, then how to enable this options and How to work with Next ,Prevoius clicks fetching infomation.

PFA.

Thanks.

green-arrows.png (1.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
DIEGO LOTHER Jul 04, 2017 at 11:50 AM
1

Hi Werner,

A sample:

Suposse you create an UDO and a form, and you connected the fields of your UDO to your form fields.

So, suppose you have an edittext called edtCode and you bind it with your primary key of your UDO, in this sample: "Code", after this, you only need set the property DataBrowser of your form with the unique id of your editText, then your green arrows will be enabled.

My user form:

My first editText connected with Code field of my UDO.

My DataBrowser property:

It is possible to do the same things by c# or vb code.

Hope it helps.

Kind Regards,

Diego Lother


img1.png (2.3 kB)
img2.png (23.3 kB)
img3.png (12.4 kB)
Show 23 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Diego Lother,

Thank you for your prompt replay,

But, In my case, I have created User Defined Form in Visual Studio(C#) not in SAP Business one Studio,

oCreationParams.UniqueID = "FP_TaskTypeForm";
oItem = oForm.Items.Add("lblSub", SAPbouiCOM.BoFormItemTypes.it_STATIC); oItem.Left = 10; oItem.Top = 90; oItem.AffectsFormMode = false; oLabel = ((SAPbouiCOM.StaticText)(oItem.Specific)); oLabel.Caption = "Subject"; oItem = oForm.Items.Add("txtCode", SAPbouiCOM.BoFormItemTypes.it_EDIT); oItem.Left = 70; oItem.Top = 10; oItem.Width = 165; oItem.AffectsFormMode = false; oItem.Enabled = false; above my sample code for creating user form, even in my code, i have given Form UniqeID also. In this case how can i enable green arrows. Thanks,
0

Hi Werner,

No problem, you set all this property by code:

The bind of udo field on your editText:

EditText oEdit = (EditText)oItem.Specific;
oEdit.DataBind.SetBound(true, "your table", "your field");

In your form set up the DataBrowser.BrowserBy property, like this:

oForm.DataBrowser.BrowseBy = "edtCode";

Hope it helps.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hello Lother,

Thanks for you replay.

But it's thrown error message "Table not found [131-183]" . Even i have given proper Table name and field name.

Thanks.

0

Hi Werner,

In this line:

oEdit.DataBind.SetBound(true, "your table", "your field");

Before you put your valid table on the second parameter, you need create a DBDataSource.

Like this:

DBDataSource db = oForm.DataSources.DBDataSources.Add("OCRD"); //Replace OCRD with your table
oEdit.DataBind.SetBound(true, "OCRD", "CardCode");//Replace the second parameter with your table, and the third parameter with your table field.

Hope it helps.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Diego Lother,

Thank you for you replay,

it's running without exception, but still green arrows are not enabled. still green buttons in disable mode onlt.

Thanks.

0

Werner,

A full sample, look this:

            SAPbouiCOM.FormCreationParams creationPackage = oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams);


            creationPackage.FormType = "MyForm";
            creationPackage.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed;

            SAPbouiCOM.Form oForm = oApplication.Forms.AddEx(creationPackage);

            SAPbouiCOM.DBDataSource db = oForm.DataSources.DBDataSources.Add("OCRD"); //Replace OCRD with your table
            SAPbouiCOM.EditText edtCode = oForm.Items.Add("edtCode", SAPbouiCOM.BoFormItemTypes.it_EDIT).Specific;
            edtCode.DataBind.SetBound(true, "OCRD", "CardCode");
            edtCode.Item.Top = 20;
            edtCode.Item.Left = 10;
            edtCode.Item.Width = 80;
            edtCode.Item.Height = 20;

            SAPbouiCOM.EditText edtCardNAme = oForm.Items.Add("edtCName", SAPbouiCOM.BoFormItemTypes.it_EDIT).Specific;
            edtCardNAme.DataBind.SetBound(true, "OCRD", "CardName");
            edtCardNAme.Item.Top = 20;
            edtCardNAme.Item.Left = 95;
            edtCardNAme.Item.Width = 200;
            edtCardNAme.Item.Height = 20;

            oForm.DataBrowser.BrowseBy = "edtCode";
            oForm.Visible = true;

Hope it helps.

Kind Regards,

Diego Lother

0

Hi Werner,

Please share the code that you use for create your form.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Lother,

Code:

  oItem = oForm.Items.Add("txtCode", SAPbouiCOM.BoFormItemTypes.it_EDIT);
                oItem.Left = 70;
                oItem.Top = 10;
                oItem.Width = 165;
                oItem.AffectsFormMode = false;
                oItem.Enabled = false;
EditText oEdit = (EditText)oItem.Specific;
DBDataSource db = oForm.DataSources.DBDataSources.Add("OCRD"); 
oEdit.DataBind.SetBound(true, "OCRD", "CardCode");
//oForm.DataBrowser.BrowseBy = "edtCode";

I'm also working OCRD table fileds only in my UDF and i have commented this line oForm.DataBrowser.BrowseBy = "edtCode"; if im uncomment this line, return exception like Item - Invalid item [66000-3]
Thanks,



0

Hi Werner,

You receive an exception because you create your EditText with the Unique id equals txtCode, so, you need txtCode on DataBrowser.BrowseBy property or change txtCode to edtCode.

I suggest you run my code above and see how it works.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Diego Lother,

Thank you for yours prompt help.

It's working very fine, But, While trying to assign same code into User defined Fileds (ex:U_WID_UserName), it's thrown exception "Date Source - Alias not Found", here i already tried with UDF actual name and also Alias name.

Please suggest me,if i'm missing anything.

And also please provide me how to bind drop down values while click next,Prevoius clicks , i mean same steps need to follw or any other code for drop down values binding.

Thanks,

0
Former Member
Former Member

Hi Diego Lother,

Item -Failed binding data[66000-57] . error return now.

Thanks.

0

Hi Werner,

About first error, you need use the field name like is in the database. If doesn't work, try to logout and login in your Sap business one client.

About your combobox, you should do the bind like we did with edittext. For your combobox have valid values to select you need add this valid value like this:

combobox.ValidValues.Add("1", "Value 1");
combobox.ValidValues.Add("2", "Value 2");

In general you populate the valid values of your combobox when you create your form.

Hope it helps.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Diego Lother,

even i have restrated SAP B1 same error message return.

Item -Failed binding data[66000-57].

this is my code

oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "U_WID_behaviour");

here 'U_WID_behaviour' is user defined filed and Table filed name shows as behaviour.

Thanks.

0
Show more comments
Former Member

Hi Diego Lother,

Your shared code working fine in my side also, but while I'm adding UDF (My User defined Filed is U_WID_behaviour) adding this lines , then it's return exception "Item -Failed binding data[66000-57]."

Code,Name,DocEntry this fileds are working fine, but problem with User defined Filed.

Can you please suggest me , if i'm missing anything here.

//Code
oItem = oForm.Items.Add("txtCode", SAPbouiCOM.BoFormItemTypes.it_EDIT); oItem.Left = 70; oItem.Top = 10; oItem.Width = 165; oItem.AffectsFormMode = false; oEdit = ((SAPbouiCOM.EditText)(oItem.Specific)); DBDataSource db = oForm.DataSources.DBDataSources.Add("@WID_FP_TASKTYPE"); oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "CODE"); oForm.DataBrowser.BrowseBy = "txtCode"
//Name
oItem = oForm.Items.Add("txtName", SAPbouiCOM.BoFormItemTypes.it_EDIT); oItem.Left = 70; oItem.Top = 30; oItem.Width = 165; oItem.AffectsFormMode = false; oItem.Enabled = false; oEdit = ((SAPbouiCOM.EditText)(oItem.Specific)); oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "Name"); oForm.DataBrowser.BrowseBy = "txtName";
//Behaviour
oItem = oForm.Items.Add("txtBehav", SAPbouiCOM.BoFormItemTypes.it_EDIT); oItem.Left = 330; oItem.Top = 10; oItem.Width = 165; oItem.Enabled = false; oEdit = ((SAPbouiCOM.EditText)(oItem.Specific)); oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "U_WID_behaviour"); oForm.DataBrowser.BrowseBy = "txtBehav";
"U_WID_behaviour" this is my user defined field name. above attached lines Code and Name both are working fine, but "U_WID_behaviour" only return exception.

Thanks.

0

Werner,

Did you get the exception here?

oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "U_WID_behaviour");

I saw in your code that you fill DataBrowser.BrowseBy in many places. This field must be filled with the unique id of your editText that is binded with the primary key of your table. In your case Code.

Try to remove this lines:

oForm.DataBrowser.BrowseBy = "txtName";
oForm.DataBrowser.BrowseBy = "txtBehav";

Hope it helps.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Diego Lother,

Yes, i got the exception, in this line "oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "U_WID_behaviour");",

I want to fetch all the required information into my Form, not only Unique Id filed, and also i have assign primary key into EditText.

But if i'm commented "DataBrowser.BrowseBy" lines, how to fetch data into textbox's, I mean by clicking of Next, Previous green buttons, data binging into textbox's.

And also, I already tried to comment those "DataBrowser.BrowseBy" lines, and executed code, while executing after commenting lines ,data not binded into textbox's.

oForm.DataBrowser.BrowseBy = "txtName";
oForm.DataBrowser.BrowseBy = "txtBehav";

But i got a exception "oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "U_WID_behaviour");" this line. As of my thougt User Defined Fileds need to SetBound any another way or same ?.

Please let me know if I am missing anything here. 
Thanks.
0

Hi Werner,

1. About bind, this line above is a sample of bind:

oEdit.DataBind.SetBound(true, "@WID_FP_TASKTYPE", "CODE");

This line below connect your form control with the field of table.

2. DataBrowser.BrowseBy is not a bind, with this property you define what field SAP will use to walk between the register of your table. Set up only one time, in general with the field that is binded with your primary key.

3. About your error when you bind a user field. I tested my sample with an UDO of my database and works fine. Please share a print of the properties of your field "U_WID_behaviour". Also share a print of a select in @WID_FP_TASKTYPE table.

Hope it helps.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Lother,

Thank you for your prompt replay.

PFA.

Lother, do you have any sample for, "populate dropdownlist(comboBox) values based on another dropdownlist(comboBox) change"

Thanks,

udt.png (6.5 kB)
0

Hi Werner,

Could you share full screen of udfs of your table?

About the dropdowlist, if you listen item event, you can do something like this:

if (pVal.BeforeAction)
            {
                switch(pVal.EventType)
                {
                    case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT:
                        if(pVal.ItemUID.Equals("myfirstDropDow"))
                        {
                            //then populate your second combobox
                            //First remove old values
                            SAPbouiCOM.ComboBox cb = (SAPbouiCOM.ComboBox)oForm.Items.Item("mySecondDropDown").Specific;
                            for (int i = cb.ValidValues.Count - 1; i >= 0; i--)
                            {
                                cb.ValidValues.Remove(i, BoSearchKey.psk_Index);
                            }


                            //Second populate with new values
                            cb.ValidValues.Add("1", "Value 1");
                            cb.ValidValues.Add("2", "Value 2");
                        }
                        break;
                }

Hope it helps.

Kind Regards,

Diego Lother

0
Show more comments
Former Member

Hi Diego Lother,

How to populate dropdownlist(comboBox) values based on another dropdownlist(comboBox) change , I mean,

I have two dropdownlists (comboBox) and trying to populate second dropdownlist (comboBox) based on selection of item of First dropdownlist.

Example: First dropdownlist contain "Departments" and according to the Departments the second dropdownlist should show the "Developers".

Below my sample code for bind First ComboBox values.

SAPbouiCOM.Item oItem = null;
SAPbouiCOM.EditText oEdit = null;
SAPbouiCOM.ComboBox stageIdCmBx = null;
oItem = oForm.Items.Add("ddl_Actvit", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oItem.Left = 70; oItem.Top = 70; oItem.Width = 165; oItem.AffectsFormMode = false; oItem = oForm.Items.Item("ddl_Dep"); stageIdCmBx = ((SAPbouiCOM.ComboBox)(oItem.Specific)); //Binding Drodpwn list for Stages drp_ActivityComboBox(stageIdCmBx); if (Activity != "" && Activity != "0") { ((SAPbouiCOM.ComboBox)(oForm.Items.Item("ddl_Dep").Specific)).Select(Activity, SAPbouiCOM.BoSearchKey.psk_ByValue); }

Thanks,

0
Former Member

Hi Lother,

How to clear combobox values , i mean, ComboBox doesn't clear the value if one is already selected value.

oItem = oForm.Items.Item("ddl_Subj");
                        cb = ((SAPbouiCOM.ComboBox)(oItem.Specific));
                        int Count = cb.ValidValues.Count;
                        for (int i = 0; i < Count; i++)
                        {
                            cb.ValidValues.Remove(cb.ValidValues.Count - 1, SAPbouiCOM.BoSearchKey.psk_Index);
                        }
above i writeen code for clear comboBox items. this code working fine, but doesn't clear the value if one is already selected before value. Thanks,

0