1

When I am adding a Sales Order, I have a method For VAT checking.

The method returns data in bool.

If the bool value is False the Form_DATA_Add the event should not work further it should stop the adding process.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

1 Answers1

1

You could use the BubbleEvent bool to handle whether you want the event to actually complete.

private static void OApplication_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
    {
        //Foo as your bool method
        if (Foo())
        {
            BubbleEvent = true;
        }
        else
        {
            BubbleEvent = false;
        }
    }

Something like this should do the trick but I would strongly suggest to use the SBO_SP_TransactionNotification for things like that. Also manage the BusinessObjectInfo.BeforeAction bool to determine the exact moment you want the ckecks to trigger, I would suggest to go with BusinessObjectInfo.BeforeAction = true.

  • Its not happening with this code. Form_DATA_Add event in passed even by a error on the code –  Nov 27 '19 at 13:04
  • you catch it on `BusinessObjectInfo.BeforeAction = true` and it goes through with `BubbleEvent = false;` and still the form is added? – Vyron Paschalidis Nov 27 '19 at 13:47
  • Tbh I strongly suggest to use the SBO_SP_TransactionNotification. What your are trying to do seems like the exact thing it is supposed to do and messing with the UI of the form on `FormDataEvent` is risky and, I've found, not that reliable – Vyron Paschalidis Nov 27 '19 at 13:51