Skip to Content
avatar image
Former Member

SAP B1 UI API Custom LinkedButton: the PressedAfter Event is ActionSuccess=False

Hello,

Starting with SAP B1 9.2 the custom created LinkedButton generates PressedAfter Event with ActionSuccess=False. Why? Is it a bug or new behavior?

The system LinkedButton generates PressedAfter Event with ActionSuccess=True

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 20, 2017 at 10:43 AM

    Hi Tomas,

    Could you please help to provide the sample code for both System Form and User Form that you are using?

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I missed the notification of your answear.

      Here is an example:

          public class B1EventHandler
          {
              private SAPbouiCOM.Application _application;
      
              public B1EventHandler()
              {
                  var api = new SAPbouiCOM.SboGuiApi();
                  api.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
      
                  this._application = api.GetApplication();
                  this._application.ItemEvent += this._application_ItemEvent;
              }
      
              private const string FormOITM = "150"; // Items Form
              private const string SysLinkButton = "1980000506"; // Item Group Linked Button
              private const string UsrLinkButton = "INFO21_01";
      
              private void _application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
              {
                  BubbleEvent = true;
      
                  if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.FormTypeEx == FormOITM)
                  {
                      if (pVal.BeforeAction)
                      {
                          CreateUserLinkButton(FormUID);
                      }
                  }
      
                  if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.FormTypeEx == FormOITM && (pVal.ItemUID == SysLinkButton || pVal.ItemUID == UsrLinkButton))
                  {
                      if (!pVal.BeforeAction)
                      {
                          var message = "ItemUID=" + pVal.ItemUID + (pVal.ItemUID == SysLinkButton ? " (System)" : " (User)");
                          message += "\n" + "BeforeAction=False; ActionSuccess=" + (pVal.ActionSuccess ? "True" : "False");
      
                          _application.MessageBox(message);
      
                          // do some custom handling
                      }
                  }
              }
      
              private void CreateUserLinkButton(string formUID)
              {
                  var form = _application.Forms.Item(formUID);
                  var itmgrp = form.Items.Item("39");
      
      
                  var text = form.Items.Add("INFO21_02", SAPbouiCOM.BoFormItemTypes.it_STATIC);
                  text.Left = itmgrp.Left + itmgrp.Width + 40;
                  text.Top = itmgrp.Top;
                  ((SAPbouiCOM.StaticText)text.Specific).Caption = "USER LINKED BUTTON";
      
                  var item = form.Items.Add(UsrLinkButton, SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON);
                  item.Left = itmgrp.Left + itmgrp.Width + 20;
                  item.Top = itmgrp.Top;
                  item.LinkTo = text.UniqueID;
              }
          }
      
      

      I have custom handling code to my linked button. I cannot use the LinkedButton.LinkedObject property.

      Tomas