cancel
Showing results for 
Search instead for 
Did you mean: 

Screen Code Generator

Former Member
0 Kudos

In the ScreenCode generator with version 6.5 I can build *.srl files.

The question is, Howcan I use this files in a Visual basic proyect, or how ca I use this files?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can use this to load userdefined forms much faster than adding forms and elements "on the fly".

Use the UI-API method :  uiSBOApplication.LoadBatchActions(strXml as String)

To do this you should use an XML-parser to retrive the xml-string. I use Microsoft XML-parser, v3.0.

example (preconditions : create an menu-item):

Private Sub m_conApp_MenuEvent(pVal As SAPbouiCOM.MenuEvent, BubbleEvent As Boolean)

Dim oForm as new SAPbouiCOM.Form

    If pVal.BeforeAction = True Then

        Select Case pVal.MenuUID

            Case "YOUR_FORM_UID" 'uid-parameter in srf-file

             LoadFromXML "FILENAME.srf" ' see help-function below

             Set oForm = m_conApp.Forms.Item("YOUR_FORM_UID")

             oForm.Visible = True

         End Select

    End If

End Sub

'//**********************************************************************

'// Loading form from resource-file (****.srf)

'//**********************************************************************

Private Sub LoadFromXML(FileName As String)

    Dim xmldoc As MSXML2.DOMDocument

    Dim xml_err As IXMLDOMParseError

    Set xmldoc = New MSXML2.DOMDocument

    xmldoc.async = False

    xmldoc.validateOnParse = True

    '// load the content of the XML File

    xmldoc.Load (App.Path + "Resources" + FileName)

        Set xml_err = xmldoc.parseError

        If (xml_err <> 0) Then

            debug.print "Failed loading xml-doc..."

        Else

            '// load the form to the SBO application in one batch

            uiSBOApplication.LoadBatchActions xmldoc.xml

        End If

End Sub

0 Kudos

If you have trouble loading a form from XML, try opening up the XML file and editing it by hand.  There are some characters that the Screen Painter will allow, but which are not handled as such by the XML parser because they are special characters. These include "#" and "&", for example. The parser will return xmldoc.xml = "".

When troubleshooting these issues, I have found that it is helpful to remove pieces from the XML document and testing it.  This helps to isolate the problem. For example remove an entire Item by removing everything between . Then test it again. Once you have isolated the problem, see if you can fix it by hand and re-try.

In any case, the Screen Painter makes it MUCH easier to design forms for Business One.  The other advantage of using LoadBatchActions with XML-based forms is that performance is much better.

Former Member
0 Kudos

Just to let you know, i

If you have any problem in loading the srf. with the LoadBatchActions(strXml as String)

it is beacuse we have a bug. A work around for this bug is:

1.Open a nodepad of the srf.

2. Do a enter

3. Do a backspace.

4. Saved it

and then try to load it with the above method.

Gali