Skip to Content

Hello all,

in this brief blog post i will show you how to edit sap b1 system forms without having to struggle with manually editing your form definition xml files and / or adding items in application item event discriminating by form type and so on.


keep your code neat. i’m using sdk 9.1, vs 2010 with sap b1 studio for ms visual studio

first of all open in sap b1 client the system form you’re going to customize, then open visual studio and load your addin project / solution.

/wp-content/uploads/2015/07/1_753606.png

then from tools menu choose to edit in insidie ms visual studio.

/wp-content/uploads/2015/07/2_753617.png

you will be prompted to choose which visual studio instance you’re going to use.

/wp-content/uploads/2015/07/3_753619.png

then you will find the system form ready to be edited and customized in visual studio.

/wp-content/uploads/2015/07/4_753623.png

you can add labels and buttons in wysiwyg style, attaching button click events, adding panes and objects in a visual manner, without the hassle of adding them by hand.

but most important of all you can access systemformbase class and manage events in the class without messing with application formdata and item events..


    [FormAttribute("180", "Return.b1f")]
    class Return : SystemFormBase
    {
        public Return()
        {
        }
        /// <summary>
        /// Initialize components. Called by framework after form created.
        /// </summary>
        public override void OnInitializeComponent()
        {
            this.StaticText0 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_0").Specific));
            this.EditText0 = ((SAPbouiCOM.EditText)(this.GetItem("Item_1").Specific));
            this.OnCustomInitialize();
        }
        /// <summary>
        /// Initialize form event. Called by framework before form creation.
        /// </summary>
        public override void OnInitializeFormEvents()
        {
            this.DataDeleteBefore += new DataDeleteBeforeHandler(Return_DataDeleteBefore);
        }
        void Return_DataDeleteBefore(ref SAPbouiCOM.BusinessObjectInfo pVal, out bool BubbleEvent)
        {
            //throw new NotImplementedException();
            //do your data control / validate stuff here
            BubbleEvent = true;
        }

the trick is done by the FormAttribute attribute, you can even use it in your classes to intercept system form events.

your code will be cleaner than ever, no more event routing via SBO_Application event handlers.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Mike Taylor

    Hello, this is a good guide but it’s not clear where I upload my system form back into the system.  If I edit a system form do I have to make an add-on to save my changes?  How do I save the edits?  Or is my edited system form just a clone?  The documentation for B1 Studio is not very clear what you actually do with the forms once you make one.  Thanks!

    (1) 
  2. William van Aert

    Hi Christian,

    Nice Post!

    But what happens when A System Form is changed by an upgrade of Business One?

    Will it still work or do I have to do this all over again?

    Kind Regards,

    William

    (0) 
    1. christian ponzoni Post author

      you have to edit again the form.

      by now we have adopted a different approach to edit system forms:

      1. we write a class which inherits sap system form base class

      2. we add sap graphic components ( combos etc ) by code ( we implemented our personal xml caching system in order to achieve max loading speed  )

      3. we override methods which need to be modified

      by now sap b1 studio is so buggy, undocumented, obscure and slow that we decided to write from scratch our xml cache system.. simply decided to discard it as a productive tool

      (0) 
      1. William van Aert

        Thank for your reply!

        I thought that this would be the case.

        We do the same thing, loading the custom items by xml.

        I agree that this should be the best approach.

        Kind Regards,

        William

        (0) 
  3. Marco Simoncelli

    Useful posts Christian,
    Do you use XML created/edited by SAP Bussiness One Studio or you write it manually?
    Do you use SBO_Application.LoadBatchActions to load it you create single controls by code parsing the XML?

    SDK documentation says that LoadBatchActions is faster i’ve not done comparisions yet.
    By “XML caching sistem” you mean a way to read xmls definition from file or db at addon start or only the first time a specific form is opened?
    Regarding customization in Visual Studio and standard forms, it seems that when the addon is loaded b1 is able to know wich fields have been modified in Visual Studio (probably comparing .b1f file edited in visula studio and .b1f__orig_srf that is created when the form is extracted in Visal Studio) and only these fields are set by the customization while other fields mantain the standard ed even updated configuration. It looks like it “merges” new form standard fields with the fields modified by visual studio.

     

    Kind Regars.

    Marco.

     

    (0) 

Leave a Reply