Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

How to implement sql trigger logic in plugin CRM 2013

$
0
0

Hi,

I have created a trigger in sql server for maintain version. But now I want to implement this logic on plugin. Can you tell me how to implement this trigger on plugin in CRM 2013?

CREATE TRIGGER [dbo].[PWC_TR_UpdateProposalVersion]
ON [dbo].[new_proposalBase]
After Insert
AS
declare @opportunityId uniqueidentifier
declare @total decimal(23, 10)
declare @name nvarchar(100)
declare @proposalId uniqueidentifier

set @proposalId=(select new_proposalId from inserted)
set @opportunityId=(select new_Opportunity from inserted)
set @name=(select new_name from inserted)
set @total=(select count(new_proposalId)from new_proposalBase where new_Opportunity=@opportunityId and new_name=@name)-1

begin

UPDATE [new_proposalBase]
SET
new_version=1+(@total/10)
where new_proposalId=@proposalId
end
GO


Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>