Skip to Content

how to close AddOn form after adding a record

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 11, 2014 at 03:57 PM

    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


    View Pedro Magueija's profile on LinkedIn

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 11, 2014 at 03:39 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 11, 2014 at 03:19 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 12, 2014 at 06:23 AM

    Thank you very much for your help.

    The solution suggested both by Alessandro and Pedro works for me,

    Regards.

    Add comment
    10|10000 characters needed characters exceeded