cancel
Showing results for 
Search instead for 
Did you mean: 

Re:Define New in the Combo

Former Member
0 Kudos

Hi,

I have added a 'Define New' option in the combo and if the combo select is 'Define New' then the User defined Table Form which was created with 'No Object' was called and the entry was added in that form. All his operations perform well. But my problem is after adding the values in that form the values in the User defined table form are not loaded in the combo if i close the main form and open it then only its loading in the combo. My need is when i add the value in the User defined table form the value added should be loaded in the combo. How to get it plz give me the solution.

Thanks in Advance.

Regards,

Madhavi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I guess u can reload the combobox using a recordset or try oForm.Refresh() and oForm.Update() so that the form and its datasources will get updated.

Vasu Natari.

Former Member
0 Kudos

Hi Vasu,

I tried in all that way but it work if i close and open the main form. The code follows which i have tried.

1.Reloaded the combo box :-

If (pVal.ItemUID = "CboWCType") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) Then

' Dim Frm As SAPbouiCOM.Form

If CboWCType.Selected.Value = "Define New" Then

SBO_Application.ActivateMenuItem("51205")

BubbleEvent = False

Try

Dim rs As SAPbobsCOM.Recordset

rs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

rs.DoQuery("select Code,Name from [@PSSIT_PMWCTYPE] where code is not null and Name is not Null")

' rs.DoQuery("select Code,U_desc from [@Sample]")

rs.MoveFirst()

If CboWCType.ValidValues.Count > 0 Then

For i As Int16 = CboWCType.ValidValues.Count - 1 To 0 Step -1

CboWCType.ValidValues.Remove(i, SAPbouiCOM.BoSearchKey.psk_Index)

Next

End If

For i As Int16 = 0 To rs.RecordCount - 1

CboWCType.ValidValues.Add(rs.Fields.Item(1).Value, rs.Fields.Item(0).Value)

rs.MoveNext()

Next

CboWCType.ValidValues.Add("Define New", "")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

in the place of combo reload i tried Form.Refresh and Form. Update() but both are not working well. Plz tell me where i go wrong here.

Regards,

Madhavi

Former Member
0 Kudos

Hi..

try this one

If (pVal.ItemUID = "CboWCType") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) Then

' Dim Frm As SAPbouiCOM.Form

If CboWCType.Selected.Value = "Define New" Then

SBO_Application.ActivateMenuItem("51205")

BubbleEvent = False

Try

Dim rs As SAPbobsCOM.Recordset

rs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

rs.DoQuery("select Code,Name from @PSSIT_PMWCTYPE where code is not null and Name is not Null")

' rs.DoQuery("select Code,U_desc from @Sample")

rs.MoveFirst()

If CboWCType.ValidValues.Count > 0 Then

For i As Int16 = CboWCType.ValidValues.Count - 1 To 0 Step -1

CboWCType.ValidValues.Remove(i, SAPbouiCOM.BoSearchKey.psk_Index)

Next

End If

Try

If RS.EoF = False Then

For i = 1 To RS.RecordCount

CboWCType.ValidValues.Add(RS.Fields.Item("0").Value, i,

rs.MoveNext()

Next

' CboWCType.ValidValues.Add("-9", "Define New")

End If

CboWCType.ValidValues.Add("-9", "Define New")

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

Regards...

Billa 2007

Former Member
0 Kudos

Hi Billa,

Its not working. Please give another solution.

Madhavi.

Former Member
0 Kudos

Madhavi,

Plz try writing ur combo reload code in the et_FORM_ACTIVATE event instead of the combo select event.

So when u define a new entry for ur combo box and after that ur form becomes active, then ur combo will be reloaded.

Vasu Natari.

Former Member
0 Kudos

Hi...

Normally i am doing i design new form(Define New) that form i give in put and Add. that one store in user defined table that table i retrieve the select query.

use this code menu event

LoadFromXmlshiftmain("Ur Main form.srf")

oForm = SBO_Application.Forms.Item("Ur Form-ID")

Try

ocombo = oForm.Items.Item("Ur-ID").Specific

RS = Nothing

RS = OCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RS.DoQuery("Select Ur table")

Try

If RS.EoF = False Then

For i = 1 To RS.RecordCount

ocombo.ValidValues.Add(RS.Fields.Item("Ur-Field").Value, i)

RS.MoveNext()

Next

'ocombo.ValidValues.Add("-9", "Define New")

End If

ocombo.ValidValues.Add("-9", "Define New")

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

************************

Private Sub LoadFromXmlshiftmain(ByVal fileName As String)

Dim XmlDoc As Xml.XmlDocument

Dim Xmlstr As String

XmlDoc = New Xml.XmlDocument

Dim SPath As String

Try

SPath = IO.Directory.GetParent(Application.StartupPath).ToString

XmlDoc.Load("C:\Program Files\SAP\SAP Business One\AddOns\Ur srf folder" & "\" & fileName)

SBO_Application.LoadBatchActions(XmlDoc.InnerXml)

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End Sub

******************************

Item Event

If pVal.FormUID = "xxx" And pVal.ItemUID = "yyy" And pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT Then

Try

ocombo = FormS.Items.Item("5").Specific

If ocombo.Selected.Value = "-9" Then

LoadFromXmlShift("Ur-definenew.srf")

End If

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

Regards...

Billa 2007

Former Member
0 Kudos

Hi Vasu,

I reloaded the combo in the et_Form_Activate but still not working. Please tell me where i go wrong in the code. The Code follows:-

If (pVal.ItemUID = "CboWCType") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE) Then

Try

Dim rs As SAPbobsCOM.Recordset

rs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

rs.DoQuery("select Code,Name from @PSSIT_PMWCTYPE where code is not null and Name is not Null")

rs.MoveFirst()

If CboWCType.ValidValues.Count > 0 Then

For i As Int16 = CboWCType.ValidValues.Count - 1 To 0 Step -1

CboWCType.ValidValues.Remove(i, SAPbouiCOM.BoSearchKey.psk_Index)

Next

End If

For i As Int16 = 0 To rs.RecordCount - 1

CboWCType.ValidValues.Add(rs.Fields.Item(1).Value, rs.Fields.Item(0).Value)

rs.MoveNext()

Next

CboWCType.ValidValues.Add("Define New", "")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

Madhavi

Former Member
0 Kudos

R getting any error?? or is ur code not executing at all.... please put a break point and debug ur code. See if its executing the code, and plz check ur event filters.

Vasu Natari.

Former Member
0 Kudos

Hi Vasu,

I am not getting any errors i checked keeping break point its not going inside the Form Active. What should i do?.

Madhavi

Former Member
0 Kudos

Hi,

The condition what u have wrote is wrong write this...

If (pVal.FormTypeEx = "UR form type") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE) Then

try that...

Vasu Natari.

Former Member
0 Kudos

Hi Vasu,

Thanks its working well the combo is displaying 'Define New' insted of that it should display the last added value how to get it.

Madhavi

Former Member
0 Kudos

R u talking abt the selected value..?? Do u mean to say that the newly added value should be displayed as the selected value in the combo..??

Then u can expliccitly select the value. use

oCOmbo.Select() and pass the correct parameters and index it will be selected.

Vasu Natari.

Answers (1)

Answers (1)

Former Member
0 Kudos

hi,

madhavi

try to reload combo after adding new one from define new using...

If pVal.FormUID = "DefineNew FormUID" And pVal.ActionSuccess = True And pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.ItemUID = "1" And pVal.FormMode = 3 Then

Try

RS1 = Nothing

RS1 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RS1.DoQuery("select U_DefineNew from [@Table] ")

Dim oCombo As SAPbouiCOM.ComboBox = oForm.Items.Item("ItemUID").Specific

For j = oCombo.ValidValues.Count - 1 To 0 Step -1

oCombo.ValidValues.Remove(j, SAPbouiCOM.BoSearchKey.psk_Index)

Next

For i = 1 To RS1.RecordCount

If RS1.EoF = False Then

oCombo.ValidValues.Add(RS1.Fields.Item("U_DefineNew").Value, i)

End If

RS1.MoveNext()

Next

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

above code helps you

regards,

varma