Hi,
Wrote a simple plugin to check the value of InputParameters being passed on update of lead record.
public void Execute(IServiceProvider serviceProvider) { IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); Entity myEntity = (Entity)context.InputParameters["Target"]; // Get the attribute collection AttributeCollection myAttColl = myEntity.Attributes; // Write in a log file TextWriter log = TextWriter.Synchronized(File.AppendText(@"C:\InputParameterLog.txt")); log.WriteLine("Log generated at " + DateTime.Now); log.WriteLine(); foreach (KeyValuePair<string, object> myKV in myAttColl) { log.WriteLine("Key - " + myKV.Key); if (myKV.Value == null) { log.WriteLine("Value - null"); } else if (myKV.Value.GetType()== typeof(EntityReference)) { EntityReference eRef = myKV.Value as EntityReference; log.WriteLine("Id - " + eRef.Id.ToString()); log.WriteLine("Logical Name - " + eRef.LogicalName); log.WriteLine("Name - " + eRef.Name); } else if (myKV.Value.GetType() == typeof(OptionSetValue)) { OptionSetValue oSetValue = myKV.Value as OptionSetValue; log.WriteLine("OptionSetValue - " + oSetValue.Value); } else { log.WriteLine("Value - " + myKV.Value.ToString()); } log.WriteLine(); } log.WriteLine(); log.Close(); }
Haven’t tested it though, might be useful while debugging.
Bye.
this works great…thanks Nishant
LikeLike