on 10-04-2017 4:41 PM
Hi all,
I tried to change the title of Sales Blanket Agreement form to Investment in SDK by using visual basic but the helped codes I got are in C#, I am not good in C#.
How can I add ItemEvent in C# in order to use below codes for changing form title.
On your ItemEvent, add the code below:
if(pVal.BeforeAction && pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.FormTypeEx == "1250000100")
{
SAPbouiCOM.Form oForm = SBO_Application.Forms.Item(FormUID);
oForm.Title = "Investment";
}<br>
I tried to search how I can add ItemEvent in C# but there is no success.
Please anyone can help me
Hi Rurangwa,
Your application should have only code in unique language or C# or VB. You can easily convert the code above from C# to VB with http://converter.telerik.com/.
The code converted to VB:
If pVal.BeforeAction AndAlso pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD AndAlso pVal.FormTypeEx = "1250000100" Then
Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(FormUID)
oForm.Title = "Investment"
End If
About how to use ItemEvent you can see the samples provided on the SDK folder.
C#:
C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\CSharp\11.SystemFormManipulation
VB:
C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\11.SystemFormManipulation
Hope it helps.
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diego,
That's very good,
I tried to edit the codes in C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\11.SystemFormManipulation and I added the codes you provided in ItemEvent (but in 11.SystemFormManipulation) if I press run button in VB it runs successfully and then if I click Sales Blanket Agreement form in SAP B1 it brings title Investment title, but if I click Add, Previous, Next or Find button in tool bar the form displays original titles.
How can I solve that problem?
That's the codes I used
Public Class SystemForm
Private WithEvents SBO_Application As SAPbouiCOM.Application
Private Sub SetApplication()
Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
SboGuiApi = New SAPbouiCOM.SboGuiApi()
sConnectionString = Command()
SboGuiApi.Connect(sConnectionString)
SBO_Application = SboGuiApi.GetApplication()
End Sub
Public Sub New()
MyBase.New()
SetApplication()
End Sub
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If pVal.BeforeAction AndAlso pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD AndAlso pVal.FormTypeEx = "1250000100" Then
Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(FormUID)
oForm.Title = "Investment"
End If
End Sub
End Class
Please anyone can help me
Hi Diego,
As it seems ItemEvent is not working with MenuEvent
So I tried to add the following codes of MenuEvent but there is one error
Private Sub SBO_Application_MenuEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
If pVal.BeforeAction AndAlso pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD AndAlso pVal.FormTypeEx = "1250000100" Then
Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(FormUID)
oForm.Title = "Investment"
End If
End Sub
The error found to MenuEvent to this line Handles SBO_Application.MenuEvent
Error1Method 'Private Sub SBO_Application_MenuEvent(FormUID As String, ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)' cannot handle event 'Public Event MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)' because they do not have a compatible signature.
How can I solve this error? I think this can allow the form to continue to display Investment title even if I click menu buttons
Please help me
Hi Rurangwa,
It is a strange situation. By menuEvent you can do this something like this:
Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
If pVal.MenuUID.Equals("1288") Or pVal.MenuUID.Equals("1289") Or pVal.MenuUID.Equals("1290") Or pVal.MenuUID.Equals("1291") Then
If SBO_Application.Forms.ActiveForm.TypeEx.Equals("1250000100") Then
SBO_Application.Forms.ActiveForm.Title = "Investiment"
End If
End If
End Sub
But really I didn't like the effect of this situation. Unfortunately I don't have any other approach for this situation.
Kind Regards,
Diego Lother
Exactly, right and very good Diego!!!!!! That's what I wanted before. Please allow me to ask you one more simple question I edited all that codes in sample of C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\11.SystemFormManipulation, so will I create and package addon from this sample or I will add that codes in system form which I will import it in Visual Studio? Thank you for your help
Hi Rurangwa,
That works best for you. But I suggest you create your project. Only remember that the SystemForm sample there are more code that can be not necessary for you.
Kind Regards,
Diego Lother
User | Count |
---|---|
106 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.