Is anyone aware of a guide to writing service interceptors? I have the REST API Documentation which has a small section, but really looking for information on what references I need to include, how to setup the development environment, any actions such as user authentication that need to be completed?
A HelloWorld interceptor tutorial that goes through these would be so helpful if anyone has one...
USE [impresario]GO/****** Object: StoredProcedure [dbo].[LP_MTC_INTERCEPTION_STOP_EMAIL_LOGIN_DUP] Script Date: 12/15/2014 08:49:00 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER procedure [dbo].[LP_MTC_INTERCEPTION_STOP_EMAIL_LOGIN_DUP]@EMAILADDRESS VARCHAR(200)=NULLAS/*[LP_MTC_INTERCEPTION_STOP_EMAIL_LOGIN_DUP] 'b.gu@mtc.com.au'*/BEGIN DECLARE @TMP INT SET @TMP =0 IF EXISTS(SELECT TOP 1 * FROM LTR_ACCEPTABLE_DUP_EMAILS WHERE EMAILADDRESS=@EMAILADDRESS) BEGIN SET @TMP =-1 END ELSE BEGIN IF NOT EXISTS(SELECT TOP 1 * FROM T_EADDRESS WHERE address=@EMAILADDRESS AND inactive='N' ) BEGIN SET @TMP =-1 END ELSE BEGIN SELECT TOP 1 @TMP=customer_no FROM T_EADDRESS WHERE address=@EMAILADDRESS AND inactive='N' END END Select @TMP as customer_no RETURN;END
<PluginConfigs> <PluginConfig> <UriMatch>CRM/ElectronicAddresses</UriMatch> <Verb>POST</Verb> <FullPluginName>MTC_REST.TessituraPlugins.ConstituentService.DupEmailLoginPrevention</FullPluginName> <PluginPlacement>PRE</PluginPlacement> </PluginConfig> <PluginConfig> <UriMatch>CRM/ElectronicAddresses</UriMatch> <Verb>PUT</Verb> <FullPluginName>MTC_REST.TessituraPlugins.ConstituentService.DupEmailLoginPrevention</FullPluginName> <PluginPlacement>PRE</PluginPlacement> </PluginConfig> <PluginConfig> <UriMatch>CRM/Constituents/*/Snapshot</UriMatch> <Verb>POST</Verb> <FullPluginName>MTC_REST.TessituraPlugins.ConstituentService.DupEmailLoginPreventionSnapshot</FullPluginName> <PluginPlacement>PRE</PluginPlacement> </PluginConfig> <PluginConfig> <UriMatch>CRM/Constituents/*/Snapshot</UriMatch> <Verb>PUT</Verb> <FullPluginName>MTC_REST.TessituraPlugins.ConstituentService.DupEmailLoginPreventionSnapshot</FullPluginName> <PluginPlacement>PRE</PluginPlacement> </PluginConfig> <PluginConfig> <UriMatch>CRM/Constituents/*/Snapshot</UriMatch> <Verb>GET</Verb> <FullPluginName>MTC_REST.TessituraPlugins.ConstituentService.HelloInterceptor</FullPluginName> <PluginPlacement>POST</PluginPlacement> </PluginConfig></PluginConfigs>
namespace MTC_REST.TessituraPlugins.ConstituentService{ public class DupEmailLoginPrevention { public static PluginData Operation(PluginData input) { string update = string.Empty; string insert = string.Empty; update = @"PUT"; insert = @"POST"; if (input.Verb == insert) { var Email = SerializationHelper.Deserialize<ElectronicAddress>(input.Data); var myEmail=input.Data; if (myEmail.Name.ToString().ToLower().Contains("electronicaddress")) { string EmailAddress = string.Empty; int mycheck = 0; EmailAddress = Email.Address.ToString(); mycheck = checkEmail(EmailAddress); if (mycheck > 0) { throw new PluginValidationException("Email Address is already under another account " + mycheck.ToString() + ". It is not allowed for this account."); } } return input; } else if (input.Verb == update) { var Email = SerializationHelper.Deserialize<ElectronicAddress>(input.Data); var myEmail = input.Data; if (myEmail.Name.ToString().ToLower().Contains("electronicaddress")) { string EmailAddress = string.Empty; int mycheck = 0; EmailAddress = Email.Address.ToString(); mycheck = checkEmail(EmailAddress); if (mycheck > 0) { throw new PluginValidationException("Email Address is already under another account " + mycheck.ToString() + ". It is not allowed for this account."); } } return input; } else { return input; } } public static int checkEmail(string emailaddress) { string tmp = string.Empty; int myreturn = 0; var sqlCommandHelper = new SqlCommandHelper(); var sqlStatement = "dbo.LP_MTC_INTERCEPTION_STOP_EMAIL_LOGIN_DUP"; var parameters = new Dictionary<string, string>(); parameters.Add("@EMAILADDRESS", emailaddress); System.Data.DataSet ds= sqlCommandHelper.ExecuteSqlCommandReturnDataSet(sqlStatement, parameters, true); System.Data.DataTable tb = ds.Tables[0]; if (tb.Rows.Count>0) { tmp = tb.Rows[0]["customer_no"].ToString(); } if (tmp.Trim().Length > 0) { myreturn =Convert.ToInt32( tmp.Trim().ToString()); } return myreturn; } }}
Hi All,Good day.those are the code for my plugin.LTR_ACCEPTABLE_DUP_EMAILS is a custom table keeping duplicated emails exceptions.The plugin worked on POST method, but it never worked on PUT method.Am I missing something?have funBen
Hi All,Good day.Patrick Drew from Sydney Theatre Company told me the trick.
if plugin uses PUT method, the config should have a * included.
if plugin uses POST method, the config should not have a * included.
Here is an example from Patrick.
Normal 0 false false false EN-AU ZH-CN X-NONE MicrosoftInternetExplorer4
Scenario
Verb
URI
Placement
New constituent record created
POST
CRM/Constituents/Snapshot
PRE
Existing constituent record, email updated from general tab
PUT
CRM/ElectronicAddresses/*
Existing constituent record, email added from contact details tab
CRM/ElectronicAddresses
Thank you Patrcik.
Have fun.
Ben
Hi Ben,
We've lodged a TASK ticket for a very similar issue. I don't think it's appearing in the Tessitura known defects list yet, but will be there soon as reference #71283.
The issue is that plugins fired from the General Tab are unable to return Validation Exception messages to the application and instead throw the errors you are seeing. There is no fix at this point.
CheersSarah