TR_CONSTITUENT_UPDATE_ISORGANIZATION
Definition
Copy
CREATE trigger TR_CONSTITUENT_UPDATE_ISORGANIZATION on dbo.CONSTITUENT after update not for replication
as begin
if update(ISORGANIZATION)
begin
declare @DOCHECK bit = 1
if exists(select 'x' from sys.OBJECTS where NAME = 'UFN_B2T_CONTEXTISSYNC')
if dbo.UFN_B2T_CONTEXTISSYNC() = 1
set @DOCHECK = 0
if @DOCHECK = 1
begin
update dbo.CONSTITUENT set ISORGANIZATION=1
from inserted
where inserted.ID=CONSTITUENT.ID
and CONSTITUENT.ISORGANIZATION=0
and exists (select ID from dbo.ORGANIZATIONDATA where ID=CONSTITUENT.ID)
if @@rowcount>0
raiserror('Constituents with organization data cannot be set as individuals.', 13, 1)
end
end
end