using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
namespace IS
{
public class AccountPreCreate: IPlugin
{
public void Execute(IPluginExecutionContext context)
{
// Verify we have an entity to work with
if (context.InputParameters.Properties.Contains("Target") && context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];
// Verify that the entity represents an account.
if (entity.Name == EntityName.account.ToString())
{
// Generate a new Account Number
Random rndgen = new Random();
StringProperty accountNumber = new StringProperty("accountnumber", rndgen.Next().ToString());
entity.Properties.Add(accountNumber);
}
}
}
}
}
using System.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
namespace IS
{
public class AccountPreCreate: IPlugin
{
public void Execute(IPluginExecutionContext context)
{
// Verify we have an entity to work with
if (context.InputParameters.Properties.Contains("Target") && context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];
// Verify that the entity represents an account.
if (entity.Name == EntityName.account.ToString())
{
// Generate a new Account Number
Random rndgen = new Random();
StringProperty accountNumber = new StringProperty("accountnumber", rndgen.Next().ToString());
entity.Properties.Add(accountNumber);
}
}
}
}
}