private void CheckInitialValue(XrmEntityPlugin plugin) { //a count aggregate should be initialised to zero when the record created if (plugin.MessageName == PluginMessage.Create && plugin.Stage == PluginStage.PreOperationEvent && plugin.TargetType == RecordTypeWithAggregate) { if (NullAmount != null) { plugin.SetField(AggregateField, NullAmount); } } }
public void SetInitialValues(XrmEntityPlugin plugin) { //a count Rollup should be initialised to zero when the record created if (plugin.MessageName == PluginMessage.Create && plugin.Stage == PluginStage.PreOperationEvent) { var RollupsToProcess = GetRollupsForRollupType(plugin.TargetType); foreach (var Rollup in RollupsToProcess) { if (Rollup.NullAmount != null) { plugin.SetField(Rollup.RollupField, Rollup.NullAmount); } } } }