SoftadminApi.SavedSearch_InsertUpdate

Type: Stored procedure

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.

Example

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;

Return value: int

Returns a negative value on failure.

Parameters

@Id mandatory int
SearchID.
@MenuItemId mandatory int
@SaveAsNewSearch mandatory bit
If 1 a new search is created even if @id is not null.
@SavedSearchGroupId mandatory int
@SearchName mandatory varchar(300)
@UserID mandatory int