Skip to Content

B1 SDK: Creating Alerts Dynamically for Alerts Management

I want to know if it possible to create saved alerts in the SDK and attach it to query for Alerts Management? The reason for this is I have a customer I need to setup multiple alerts for multiple databases. It would take a lot of time setting this all up in the B1 Client. I figure it would be quicker if I used the SDK to archive this task so I can have it create the same queries for all database and the reference the alert I need for each query.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 13, 2017 at 08:44 PM

    Hi Willian,

    Yes, it is possible.

    You should use the object UserQueries for create your saved queries and then use the service AlertManagementService for create alerts.

    For create alerts there is a sample in SDK help:

    Add a user alert

    'get alert
    Dim oAlertManagement As AlertManagement
    Dim oAlertManagementParams As AlertManagementParams
    Dim oAlertManagementRecipients As AlertManagementRecipients
    Dim oAlertRecipient As AlertManagementRecipient
    'Assuming that oAlertManagementService is already defined!
    'Get alert
    oAlertManagement = oAlertManagementService.GetDataInterface(AlertManagementServiceDataInterfaces.atsdiAlertManagement)
    'set alert name
    oAlertManagement.Name = Alert1
    'set query
    oAlertManagement.QueryID = 34
    'activate the alert
    oAlertManagement.Active = BoYesNoEnum.tYES
    'set priority
    oAlertManagement .Priority = AlertManagementPriorityEnum.atp_High
    'Set the Frequency
    oAlertManagement .FrequencyInterval = 1
    ' set the Frequency type to hours
    oAlertManagement.FrequencyType = AlertManagementFrequencyType.atfi_Hours
    'get Recipients collection
    oAlertManagementRecipients = oAlertManagement.AlertManagementRecipients
    'add recipient
    oAlertRecipient = oAlertManagementRecipients.Add()
    'set recipient code(manager=1)
    oAlertRecipient.UserCode = 1
    'set internal message
    oAlertRecipient.SendInternal = BoYesNoEnum.tYES
    'add alert
    oAlertManagementParams = oAlertManagementService.AddAlertManagement (oAlertManagement )

    The parameter QueryId should receive the id of your object UserQueries.

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded