Getting the IncidentId on resolving a Case in post Close plugin.

Hi,

To get the id of the case record which is getting resolved in the plugin, we need to make use of IncidentResolution inputparameters of the context.


Entity incRes = this.Context.InputParameters["IncidentResolution"] as Entity;
 Guid caseId = ((EntityReference)incRes.Attributes["incidentid"]).Id;

Bye.

Advertisements

Use “Close” message when we “Resolve” an Incident (Case) in CRM.

We had one plugin which was registered against “SetState” and “SetStateDynamic” message. It used to run when we were doing “Cancel Case” from the ribbon.

We thought the same message will work in case of “Resolve Case“.

However in case of Resolve Case, we need to use or register our plugin against the “Close” message.

InputParametersà

Hope it helps.

System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. -2147220970

Hi,

At times we have got this error while saving our record in CRM. It can occur if we have mistakenly registered steps of one of our plugins to some other plugins. Please check in plugin registration tool and delete those steps.

Hope it helps.

Plugin to check the InputParameters value of the Context in CRM 2011.

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.