Skip to Content
author's profile photo Former Member
Former Member

oForm

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)

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2015 at 04:24 AM

    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/

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 21, 2015 at 06:51 AM

    Hi,

    Try to put

    oCreationParams.FormType="-1" .

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 21, 2015 at 06:51 AM

    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 Former Member that Xml based forms are the recommended way of creating forms.


    Best regards,

    Pedro Magueija


    View Pedro Magueija's profile on LinkedIn

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2015 at 08:50 PM

    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")


    Sin título.png (112.3 kB)
    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.