Use the Messages window to display and manage all comm server message types.
Select the Services tab.
Click Messages (). The following screen will appear.
Click the Add button () in the bottom left corner.
In the Description field enter a unique description to identify the message.
In the Queue Size field enter how many messages can be cached for monitoring purposes.
In the Procedure list you can specify a custom stored procedure to be executed when a message is received.
Only stored procedures that have a name starting with CUSTOM_ will be listed.
If required, click Import Fields. The fields required for the stored procedure will be added to the Fields section.
In the Fields section specify the labels that the message will contain.
Please note that Label keys are case sensitive. If the Import Fields function is used, labels are imported in lower case. Please ensure that the Label keys match the case found in the input file.
Click the Add button () in the Fields section to add a new label.
Enter a Description of the label (this doesn't have to be the actual label).
Enter a Label Key.
Click Save. The label is added to the list.
Click OK . The message is added.
The example below details a stored procedure that can be used to return a custom error in Cockpit using a raiserror statement.
The stored procedure checks to see if the provided serial and color code to be used exists and if not, returns a custom error message that includes the serial number or color code provided to the stored procedure and sends it to the Comm Service screen in Cockpit.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [custom].[custom_comsvs_store_unit_color]
@Serial nvarchar(20),
@colorCode nvarchar(20),
@colorType nvarchar(20)
as
begin
set nocount on
declare
@unitID int,
@colorID int,
@colorTypeID int
-- Try to find unit
select top 1 @unitID = unit_id
from unit_identifiers
where identifier = @serial
and identifier_type_id = 1
order by unit_id
-- Quit if unit is not found
if @unitID is null
begin
raiserror('ERROR: Unit not found for serial %s.', 18, 1, @Serial) with log
return
end
--try to find color
select @colorID = (select color_id
from colors
where code = @colorCode)
-- Quit if color is not found
if @colorID is null
begin
raiserror('ERROR: Color not found for Color code %s.', 18, 1, @colorCode) with log
return
end
--try to find color Type
select @colorTypeID = (select color_type_id
from unit_color_types
where code = @colorType)
-- Quit if color type is not found
if @colorTypeID is null
begin
raiserror('ERROR: Color type not found for Color Type code %s.', 18, 1, @colorType) with log
return
end
begin transaction
-- Insert Unit Color
insert into unit_colors
(unit_id, color_type_id, color_id)
values
(@unitID, @colorTypeId, @colorID)
commit
end
An example message without errors:
An example message with errors:
Can we improve this topic?