how to edit system forms with the new sap b1 studio for microsoft visual studio
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.
then from tools menu choose to edit in insidie ms visual studio.
you will be prompted to choose which visual studio instance you’re going to use.
then you will find the system form ready to be edited and customized in visual studio.
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.
Excellent post! This is exactly the straight forward information I was looking for.
Best Regards,
Heath Gardner
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!
yes, your modified system form will be present only if the addon is running.
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
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
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
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.
Thanks friend, I have searched this problem. It was useful but It doesn't appear when I select my program as running program in Visual Studio. How can I solve it?
I have the same situation... did you resolved this??.... Best regards for all...