Export (0) Print
Expand All

Sample SQL Module

CRM 1.0

The following SQL module can be used to register your callouts in the Microsoft CRM database. After this module is registered, the callout methods are triggered upon the Create, Update, and Delete events of the Account, Contact, and CustomerAddress objects.

Note   The platform caches information about subscribers only if EventMask != 0. The value for the CLSIDorProgId argument should be changed to the GUID of the class that implements the ICRMCallout interface.

[SQL]

declare @subscriberid uniqueidentifier
set @subscriberid = newid()

-- Insert Subscriber (Sample Module)
insert into Subscriber(SubscriberId, CLSIDorProgId, Name, Description) values
(@subscriberid, N'{AA4AD2AC-97B8-4d24-8E81-388A655DDBE5}',
N'My Sample Callout Module', N'')

--Insert into EntityEventSubscribers
declare @entityid uniqueidentifier

--Account(post-create, post-update, post-delete)
select @entityid = EntityId from Entity where ObjectTypeCode = 1
update Entity set EventMask = EventMask | 1 where ObjectTypeCode = 1

insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(2, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(8, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(32, @entityid, @subscriberid, 0, 1, 0)

--Contact(post-create, post-update, post-delete)
select @entityid = EntityId from Entity where ObjectTypeCode  = 2
update Entity set EventMask = 1 where ObjectTypeCode = 2

insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(2, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(8, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(32, @entityid, @subscriberid, 0, 1, 0)

--Customer Address(post-create, post-update, post-delete)
select @entityid = EntityId from Entity where ObjectTypeCode  = 1071
update Entity set EventMask = 1 where ObjectTypeCode = 1071

insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(2, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(8, @entityid, @subscriberid, 0, 1, 0)
insert into EntityEventSubscribers(EventId, EntityId, SubscriberId,
      CalloutOrder, IsEnable, IsAsyncHandler) values
(32, @entityid, @subscriberid, 0, 1, 0)


© 2005 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft