Posts Tagged ‘Plug-Ins’

   Both workflows and plug-ins can attach to exactly the same events. Well, plug-ins have available a couple of more events but essentially both work on top of the same event model.Remember also that workflows always run asynchronous and hence, the Asynchronous Processing Service must be running on the server in order to run. Workflows [...]

using System; using System.Collections.Generic; using System.Text; using Microsoft.Crm.Sdk; using Microsoft.Crm.SdkTypeProxy; using Microsoft.Crm.Sdk.Query; using System.Web.Services.Protocols; namespace CRM.Customization.AutoNumber { public class AutoNumberPlugIns:IPlugin { DynamicEntity entity = null; int startNumber; string prefix = string.Empty; string seperator = string.Empty; int nextMaxNumber; string uniqueId = string.Empty; #region IPlugin Members public void Execute(IPluginExecutionContext context) { if (context.InputParameters.Properties.Contains(“Target”) && context.InputParameters.Properties["Target"] is DynamicEntity) [...]

If we want to execute some code in behalf of another user not the calling user then we have to handle this in PlugIn code. Whatever the user selected during PlugIns registration, it doesn’t matter, code will alwaysexecute on behalf of user mentioned in code.Example Create a Record in CRM on behalf of another user. [...]

To retrieve data from CRM Database( FilteredView)….. SqlConnection connection = new SqlConnection(“DataSource=<dsName>;Initial Catalog=<databaseName> ;Integrated Security=SSPI;”); string sqlQuery = @” select max(new_uniqueid) from FilteredView” ; SqlCommand cmd = new SqlCommand(sqlQuery, connection); connection.Open();   /// Write Logic here   connection.Close();   But this code wasn’t returning any results .It was because callout/plugin run under the context of [...]