CRM2013
I have an update plugin on a custom entity. I have the need to reference the data before the record is update. I was pointed to using images to grab the data before the record is updated. Using examples from the net, I tried creating a plugin. This doesn't appear to be working, so I have cut it down, to get a working solution. Following the examples, I can not see where I am going wrong . Can anyone shed some light
Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports Microsoft.Xrm.Sdk Imports System.ServiceModel Imports Microsoft.SqlServer Imports System.IO Imports CRM2013_OriginatingAccounts.clsGlobals Imports Microsoft.Xrm.Sdk.Query Imports Microsoft.Xrm.Sdk.Messages Imports CRM2013_OriginatingAccounts.cls_SQLFunctions Namespace OAccountsUpdate Public Class cls_OAccounts_update Implements IPlugin Public Sub Execute(serviceProvider As System.IServiceProvider) Implements Microsoft.Xrm.Sdk.IPlugin.Execute Dim context As IPluginExecutionContext = DirectCast(serviceProvider.GetService(GetType(IPluginExecutionContext)), IPluginExecutionContext) ' Variables Dim strLicence As String = String.Empty Dim strOAccountID As Guid = Nothing Dim intOAccountClientID As Integer = 0 Dim strCountry As String = String.Empty Dim strBACSID As String = String.Empty Dim strSortCode As String = String.Empty Dim strAccountNumber As String = String.Empty Dim StrAccountName As String = String.Empty Dim decDailyLimit As Decimal = 0D Dim decWeeklyLimit As Decimal = 0D Dim intVarPeriodDays As Integer = 0 Dim decVarPeriodLimit As Decimal = 0D Dim decMonthlyLimit As Decimal = 0D Dim bolAllowPayments As Boolean = False Dim bolAllowDebits As Boolean = False Dim bolActive As Boolean = False Try If context.PreEntityImages.Contains("preAccountUpdate") AndAlso TypeOf context.PreEntityImages("preAccountUpdate") Is Entity Then Dim PreUpdateEntity As Entity = DirectCast(context.PreEntityImages("preAccountUpdate"), Entity) strOAccountID = New System.Guid(PreUpdateEntity.Attributes("new_accountkey").ToString) intOAccountClientID = CInt(PreUpdateEntity.Attributes("new_accountid").ToString) Throw New InvalidPluginExecutionException(strOAccountID.ToString & " ," & intOAccountClientID) End If Catch ex As Exception Throw New InvalidPluginExecutionException(ex.Message) End Try End Sub End Class End Namespace
Dont ask me .. i dont know