spCustomFormElement_DeleteByGuid
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@Guid | uniqueidentifier | IN | |
@CurrentUsersID | int | IN |
Definition
Copy
CREATE procedure [dbo].[spCustomFormElement_DeleteByGuid]
@Guid uniqueidentifier,
@CurrentUsersID int = 1
as
if exists(select * from CustomFormSettings where FormGUID = @Guid and ConfirmationEmailTemplateID > 0)
begin
declare @emailTemplateID int;
select @emailTemplateID = ConfirmationEmailTemplateID
from dbo.CustomFormSettings
where FormGUID = @Guid
exec dbo.spDelete_EmailTemplate @PKID = @emailTemplateID, @CurrentUsersID = @CurrentUsersID
end;
with CustomFormElementHierarchy as
(
select
[Guid],
[ParentID]
from
dbo.CustomFormElement
where
[Guid] = @Guid
union all
select
e.[Guid],
e.[ParentID]
from
dbo.CustomFormElement e
inner join CustomFormElementHierarchy eh on
e.ParentID = eh.[Guid]
)
delete dbo.CustomFormElement
from dbo.CustomFormElement e
join CustomFormElementHierarchy eh on
e.[Guid] = eh.[Guid]