cancel
Showing results for 
Search instead for 
Did you mean: 

oForm

Former Member
0 Kudos

Como puedo crear 2 formularios ... ya que intente crear un segundo formulario pero me dice que ya existe
--

As I can create 2 forms ... and trying to create a second form but it tells me that already exists

Dim oCreationParams As SAPbouiCOM.FormCreationParams

        oCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

        oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed

        oCreationParams.UniqueID = "Form1"

        oForm = SBO_Application.Forms.AddEx(oCreationParams)

       

Dim oCreationParams As SAPbouiCOM.FormCreationParams

        oCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

        oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed

        oCreationParams.UniqueID = "Form2"

        oForm = SBO_Application.Forms.AddEx(oCreationParams)

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

have this function to create form but to open the second tells me q already exists

Dim oCAyuda as AyudaGeneral

oCAyuda = new AyudaGeneral

'----This is the first instance:

oForm3 = oCAyuda.NuevoFormulario(Add_On.My.Resources.Pantalla_Prin, "Form3", SBO_Application, "-1")

'----This is the second instance:

oForm4 = ayudaGen.NuevoFormulario(Add_On.My.Resources.SEI_PROP_ARTICULOS, "Form2", SBO_Application, "2")

Former Member
0 Kudos

Try to include " oForm.Visible = True"

Regards,

Bry

Blog: http://www.sap-tips-tricks.com/

pedro_magueija
Active Contributor
0 Kudos

Hi Marlon,

Are you calling the "NuevoFormulario" function during an event?

Note that if you are calling the function during say a click event there will be two calls (one with BeforeAction = true and another with BeforeAction = false). If your function is called during the "before" and "after" event the second will fail with form already exists (since the UID's are hardcoded).


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

pedro_magueija
Active Contributor
0 Kudos

Hi Marlon,

Two forms cannot have the same unique id or else an exception will occur. In your code I can see that you define the unique id (with different values) but you also define twice the same variable (oCreationParams) which would in fact give an error if they are in the same scope.

So what I'd do is to check the unique id of the form you are trying to open and making sure it does not exist already. You can do this by trying to get the form oApplication.Forms.Item(uniqueId) and if it exist it will return a reference to it, if not an exception will occur (make sure to use a try/catch block).

Note that the uniqueId must be unique regardless of the method of creation (Xml or code). However I also agree with that Xml based forms are the recommended way of creating forms.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

former_member458725
Active Participant
0 Kudos

Hi,

Try to put

  oCreationParams.FormType="-1" .

Former Member
0 Kudos

Instead of doing it manually. Why not open the SAP Business One Studio? Don't make your life to complex when there's a easy way. Open your SAP B1 client > Tools > SAP BUsiness One Studio Suite > SAP Business One Studio. You can create your forms there. And when you want to open the form you can use.

        Dim oXmlDoc As System.Xml.XmlDocument

        oXmlDoc = New System.Xml.XmlDocument

        Dim sPath As String = IO.Directory.GetParent(FileName).ToString

        oXmlDoc.Load(FileName)

        SBO_Application.LoadBatchActions(oXmlDoc.InnerXml)

Regards,

Bry

Blog: http://www.sap-tips-tricks.com/