cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member183402
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

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

former_member183402
Participant
0 Kudos

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?


ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

former_member183402
Participant
0 Kudos

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?

former_member183402
Participant

Hi Ankit,

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

Thank you so much

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rurangwa Schadrack,

Glad to know that!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

peotraco1924
Explorer
0 Kudos

Hi ,

I am new user for the stored procedures on SAP B1. But is this code above can be done inside the stored procedure? Or does it need to have different platform?

Many thanks.

Gail

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi peo traco (Gail),

No, you cannot use this code inside stored procedure. It is a .NET code for SAP Business One SDK.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

peotraco1924
Explorer
0 Kudos

Thank you