Skip to Content
author's profile photo Former Member
Former Member

How can I use my validation before save ,when I click the Icon of close form?

As the picture,How can I use my Validation in my behide Code?

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 09:49 AM

    Hi Bryan,$riniva$ Rachumallu and Edy

    Thanks your ideas and Support.

    But that is our Add-on and is customization form.

    if I use the SBO_SP_TransactionNotification, I am worried it will be too much thing in one Stored Procedures.

    I use the sample of CatchingEvents, and use the event of et_FORM_CLOSE,But the order it runs is as the picture.

    I can't use my Validation after user click "Yes" .

    Can I catch the event that after user click "Yes" ?

    Remark: To use Validation that just I want to prevent user run it out of our rule.


    1111.png (15.5 kB)
    22222.png (1.3 kB)
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Remark(some of my source code):

      SBO_Application.FormDataEvent += new _IApplicationEvents_FormDataEventEventHandler(FormDataEvent);

      protected void FormDataEvent(ref BusinessObjectInfo busObj, out bool bubbleEvent)

      {

      bubbleEvent = true;

      if ((busObj.EventType == BoEventTypes.et_FORM_DATA_ADD || busObj.EventType == BoEventTypes.et_FORM_DATA_UPDATE) && busObj.BeforeAction)

      {

      if (busObj.FormTypeEx == "FORMID")

      {

      //if (!Validation())

      //{

      SBO_Application.MessageBox("Can not Save", 1, "Ok", "", "");

      bubbleEvent = false;

      //}

      }

      }

      }


  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 01:17 AM

    What information you want to validate? In this example from PO, I will block the transaction the the Project field is NULL or no value.

    IF (@object_type = '22' AND @transaction_type IN ('A', 'U'))

    BEGIN

    SELECT TOP 1

    @LineNum = a.LineNum + 1

    FROM POR1 a

    INNER JOIN OPOR b ON a.DocEntry = b.DocEntry

    WHERE (a.Project = '' OR a.Project IS NULL) AND b.DocEntry = @list_of_cols_val_tab_del

    IF NOT @LineNum IS NULL

    BEGIN

    SELECT @error = -22,

    @error_message = 'Please define project at line #. '+ @LineNum +'. '

    END

    END

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      If I were you. I would used the SBO_SP_TransactionNotification instead of creating add-on.

      If you used add-on.

      1. You will deploy it on all SAP user.

      2. You need to maintain the source code.

      3. Will cost more time.

      Don't make things so complicated if it is there's a minimal way to do it. Anyway, here's a sample to block NULL or empty value.

      Dim oNumAtCard As SAPbouiCOM.EditText

      oNumAtCard = frmManualDep.Items.Item("14").Specific

      If oNumAtCard.Value = "" Then

      MsgBox("NULL")

      End If

      There's a sample to catch the event here at :

      C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents

      Regards,

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 05:10 AM

    hi.

    Try below code..

    first i need a small information..

    which form u want to validate ..

    system form or customization form..

    i would like to support Mr.Bryan

    why dont u use sp..

    suppose u r validating system form..

    before clicking they have not started the addon .

    addon can not validate it..

    if u still need through the code

    try below sample code..

    one more information i need ..

    why u need validation at from close i am not understanding..

    normally people are closing the form after they complete the work..

    'before clicking save button

    If (pVal.FormTypeEx = "140" And pVal.BeforeAction = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) Then

    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)

    ''Do your validation

    '' above scenario for system form chagne pval.formtypex to your from uid

    End If

    If (pVal.FormUID = "yourCustomizationFormuid" And pVal.BeforeAction = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) Then

    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)

    ''Do your validation

    End If

    'Form close

    If (pVal.FormUID = "yourCustomizationFormuid" And pVal.BeforeAction = True And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE) Then

    oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)

    ''Do your validation

    End If

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 08, 2014 at 05:29 AM

    Hi Mingwei,

    Catch the event of On Before Form Close. Do your validation on the form and stop the closing event if your validation does not meet.

    Regards
    Edy

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.