Creates or updates a saved search.
This procedure is intended to be used if you override the InsertUpdate procedure of the Save search menu item by specifying your own procedure in the setting SavedSearchInsertUpdateProcedure
.
ALTER PROCEDURE dbo.MySavedSearchInsertUpdateProcedure
-- Default fields to pass to API procedure.
@Id int = NULL OUTPUT,
@SaveAsNewSearch bit = 0,
@SavedSearchGroupId int,
@MenuItemId int,
@SearchName varchar(300),
@UserId int,
-- My custom fields
@IsFavoriteSearch bit
AS
BEGIN
DECLARE @ReturnCode int;
EXEC @ReturnCode = SoftadminApi.SavedSearch_InsertUpdate
@Id = @Id OUTPUT,
@SaveAsNewSearch = @SaveAsNewSearch,
@SavedSearchGroupId = @SavedSearchGroupId,
@MenuItemId = @MenuItemId,
@SearchName = @SearchName,
@UserId = @UserId;
IF @ReturnCode = 0
BEGIN
DELETE dbo.FavoriteSearch
WHERE
SavedSearchId = @Id;
IF @IsFavoriteSearch = 1
BEGIN
INSERT dbo.FavoriteSearch (UserId, SavedSearchId)
VALUES (@UserId, @Id);
END;
END;
END;
Returns a negative value on failure.