on 09-11-2014 3:51 PM
Hello
I am implementing a AddOn that has its own form operating on User-Defined-Object.
Please tell me how can I force form to close after record is added/inserted.
I was trying to override FORM_DATA_ADD Event (after event) but neither form.Close() nor form.Items.Item("2").Click() (simulation of cancel buton) didn't work for me or caused unexpected close of SAP B1
Regards,
Pawel
Hi Pawel,
Form_Data_Add (after) event occurs before the Item_Pressed (after) event. B1 needs the form that initially triggered the Item_Pressed open (perhaps this is why you get the errors).
You could catch the Item_Pressed (after) event on the add button (id = 1) and the use the simple form.Close();
By that time no other (native) events should be triggered and the form.Close() should be successful.
Best regards,
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pawel,
you can't close the form in SBO_Application_FormDataEvent but you can tray this code:
'Declare public boolean variable
public variableAdd as boolean = False
'in SBO_Application_FormDataEvent if add is in actionSuccess set variable at true
If BusinessObjectInfo.BeforeAction = False Then
if BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then
If BusinessObjectInfo.ActionSuccess Then
variableAdd=true
end if
end if
end if
'In SBO_Application_ItemEvent after press on button "1" close form
If pVal.BeforeAction = False Then
if pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED Then
if If pVal.ItemUID = "1" Then
if variableAdd=true Then
variableAdd=false
form.Items.Item("2").Click()
end if
end if
End if
else
'set public variable to false
if pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED Then
if If pVal.ItemUID = "1" Then
if variableAdd=true Then
variableAdd=false
end if
end if
End if
end if
,Regards Alessandro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much for your help.
The solution suggested both by Alessandro and Pedro works for me,
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pawel,
Easiest is to change the Form.Mode and to set it to Ok before B1 changes it: by doing so, it will detect that the form was already in Ok mode and closes the form.
Regards,
Eric
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
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.