Skip to Content
avatar image
Former Member

Enable Alert in SAP

Hello experts ,

I would like to activate an alert where it is saved in alert management using di add-on.

How can i do this?

Kind Regards ,

Ifigeneia Koumbarda

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 12, 2017 at 12:03 PM

    Hi Ifigeneia,

    You can use the message service. The example below I got from SDK Help.You can adapt it and run a query before setting the values.

    Dim oCmpSrv As SAPbobsCOM.CompanyService
    Dim oMessageService As MessagesService
    Dim oMessage As Message
    Dim pMessageDataColumns As MessageDataColumns
    Dim pMessageDataColumn As MessageDataColumn
    Dim oLines As MessageDataLines
    Dim oLine As MessageDataLine
    Dim oRecipientCollection As RecipientCollection
    
    'get company service
    oCmpSrv = oCompany.GetCompanyService
    
    'get msg service
    oMessageService = oCmpSrv.GetBusinessService(ServiceTypes.MessagesService)
    
    'get the data interface for the new message
    oMessage=oMessageService.GetDataInterface(MessagesServiceDataInterface.msdiMessage)
    
    'fill subject
    oMessage.Subject = "My Subject"
    
    'fill text
    oMessage.Text = "My Text"
    
    'Add 
    Recipient oRecipientCollection = oMessage.RecipientCollection
    
    'Add new a recipient
    oRecipientCollection.Add()
    
    'send internal message
    oRecipientCollection.Item(0).SendInternal = BoYesNoEnum.tYES
    
    'add existing user code
    oRecipientCollection.Item(0).UserCode = "manager"
    
    'get columns data
    pMessageDataColumns = oMessage.MessageDataColumns
    
    'get column
    pMessageDataColumn = pMessageDataColumns.Add()
    
    'set column name
    pMessageDataColumn.ColumnName = "My Column Name"
    
    'get lines
    oLines = pMessageDataColumn.MessageDataLines()
    
    'add new line
    oLine = oLines.Add()
    
    'set the line value
    oLine.Value = "My Value"
    
    'send the message
    oMessageService.SendMessage(oMessage)
    Add comment
    10|10000 characters needed characters exceeded

  • May 11, 2017 at 12:54 PM

    The object is called AlertManagment

    AlertManagementService service = (AlertManagementService)this.AddOn.Company.GetCompanyService().GetBusinessService(ServiceTypes.AlertManagementService);
    
    AlertManagementParams parameters = service.GetDataInterface(AlertManagementServiceDataInterfaces.atsdiAlertManagementParams);
    
    parameters.Code = 1;
    
    AlertManagement alert = service.GetAlertManagement(parameters);
    alert.Active = BoYesNoEnum.tYES;
    
    service.UpdateAlertManagement(alert);
    
    
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Danilo Kasparian,

      I think my question was not so clear.I would like to run the funcionality of alert management.For example i would like to return the result from a query with internal alert for the user manager.I found the code below but how can i create the data from query in one string to look like table ?

      Try
                                  objMsg = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oMessages)
                                  objMsg.Subject = "1234"
                                  objMsg.MessageText = "Well Done!"
                                  objMsg.Recipients.Add()
                                  objMsg.Recipients.SetCurrentLine(0)
                                  objMsg.Recipients.UserCode = "manager"   'USID
                                  objMsg.Recipients.NameTo = "manager"     'USID
                                  objMsg.Recipients.UserType = BoMsgRcpTypes.rt_InternalUser
                                  objMsg.Recipients.SendInternal = SAPbobsCOM.BoYesNoEnum.tYES
                                  objMsg.Recipients.SendEmail = SAPbobsCOM.BoYesNoEnum.tNO
                                  objMsg.Priority = SAPbobsCOM.BoMsgPriorities.pr_High
                                  lngStatus = objMsg.Add
                              Catch ex As Exception
                              Finally
                                  If Not objMsg Is Nothing Then
                                      System.Runtime.InteropServices.Marshal.ReleaseComObject(objMsg)
                                      objMsg = Nothing
                                  End If
      End Try

      Kind Regards ,

      Ifigeneia Koumbarda