Skip to Content
0

How to set condition by using Yes or No button of message box in SAP B1?

Nov 22, 2017 at 01:34 PM

124

avatar image

Hi all,

How can I set condition by using Yes or No of message box of You cannot change this document after you have added it. Continue?

Actually I can do codes of to execute instructions before and after adding Document in SAP B1 like this

If pVal.FormType = 133 AndAlso pVal.ActionSuccess = False AndAlso pVal.EventType = BoEventTypes.et_ITEM_PRESSED AndAlso pVal.ItemUID = "1" AndAlso pVal.FormMode = 3 Then
'Instructions here
End If

But Now I want if I click Yes button of message box then execute instructions before adding document in DB, if I click No then no execution of instructions will be

Please anyone can help me

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
ANKIT CHAUHAN
Nov 22, 2017 at 01:37 PM
0

Hi,

It can be done something as below:

int ithReturnValue;
ithReturnValue = SBO_Application.MessageBox("Do you want to continue ?", 1, "Continue", "Cancel", "");

if (ithReturnValue == 1)
{
    BubbleEvent = true;
}
else
{
    BubbleEvent = false;
}

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi Ankit,

That is good, but is it possible to control the Yes button of last message box (You cannot change this document after you have added it. Continue?) of AR Invoice?


0

Hi,

Yes, it is something tricky however you can achieve it something like this:

if (pVal.FormType == 0 && pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD) 
{ 
SAPbouiCOM.Form oForm = (SAPbouiCOM.Form)SBO_Application.Forms.GetForm(pVal.FormType.ToString(), pVal.FormTypeCount); 
SAPbouiCOM.StaticText oStatic = (SAPbouiCOM.StaticText)oForm.Items.Item("7").Specific;
if (oStatic.Caption == "You cannot change this document after you have added it. Continue?") 
{ 
oForm.Close(); 
return; 
}
}

Remember to check it for the all the forms for which you want to do it. (In this case, A/R Invoice) since the FormType will always be "0" for other system forms.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

Hi Ankit,

That was exactly what I wanted but the only problem is when i press "Yes" or "No" button it still gives me the same results.And what i what is that it can only work with the "Yes"button

        If pVal.FormType = 0 AndAlso pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE Then
            Dim oFormM As SAPbouiCOM.Form = DirectCast(SBO_Application.Forms.GetForm(pVal.FormType.ToString(), pVal.FormTypeCount), SAPbouiCOM.Form)
            Dim oStatic As SAPbouiCOM.StaticText = DirectCast(oFormM.Items.Item("7").Specific, SAPbouiCOM.StaticText)
            If oStatic.Caption = "You cannot change this document after you have added it. Continue?" Then
                Dim udfFormUID As String = SBO_Application.Forms.Item(FormUID1).UDFFormUID
                Dim UDFForm As Form = SBO_Application.Forms.Item(udfFormUID)
                DirectCast(UDFForm.Items.Item("U_msgbox").Specific, EditText).Value = 20
            'oFormM.Close()
            'Return
            End If
        End If

How can control Yes and No buttons?

0

Hi Ankit,

It was done successfully, I added pVal.ItemUID = "1" in the if condition

Thank you so much

1

Hi Rurangwa Schadrack,

Glad to know that!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0