100 Filter Attribute Limitation

Jul 2, 2009 at 9:21 PM

I'm not a programmer, but this is a great tool and I need to use it.  Any way around 100 charater limitation of the attributes?  I only want about 20 fields on one tab tracked.   Any help would be appreciated.

Aug 7, 2009 at 12:13 PM
Edited Aug 10, 2009 at 9:34 AM

I had this problem too, looks something to do with the SDK as other audit plugins also suffer with the same issue.
One thing that helps is that it's only the "step" filter that is limited to 100 characters not the "image" filter - apparently this is around 4000 characters.

With this in mind you select "All attributes" at the step level and then filter at the "image" level.  Only problem is that you end up with Audit entries that have no associated detail.  (Because an entity that triggeered the update is not an entity you want to record...)

Therefore I have modifed and added the following code which must be put directly before the "// Create the audit record" part of the code.
It adds up how many fields have actually changed (from those filtered) and if there is none then the function ends before the creation of the audit record.

This will need recompiling back to a .dll and the plugin will need updating using the registration tool.

One final thing this records the number of changes in the audit record as long as the name is "new_totalchanges" change the last line or remove if you do not want but I presonnaly like to see at a glance how many changes someone may have made without going into the record.

Hope this helps!

Steve

         // Steven Dudson - 07.08.09
            // Adds up the number of records that has changed
            // Process the modified records
            CrmNumber i = new CrmNumber();
            i.Value = 0;
            if (context.PostEntityImages.Contains("Target"))
            {
                // Get a reference to the images.
                DynamicEntity pre = null;
                DynamicEntity post = (DynamicEntity)context.PostEntityImages["Target"];

                // If the message is "Create" then dummy up a pre-image.
                if (context.MessageName == "Create")
                    pre = new DynamicEntity();
                else
                    pre = (DynamicEntity)context.PreEntityImages["Target"];

                // Iterate through the entity's attributes to determine change.
                foreach (AttributeMetadata metaAttribute in res.EntityMetadata.Attributes)
                {
                    // Ensure the attribute is a parent level attribute.
                    if (metaAttribute.AttributeOf == null)
                    {
                        // Get the property objects
                        object preProp = this.GetObjectFromProperty(pre.Properties, metaAttribute.LogicalName);
                        object postProp = this.GetObjectFromProperty(post.Properties, metaAttribute.LogicalName);

                        // Ensure we have at least a pre/post property.
                        bool bProcess = (preProp != null);
                        if (!bProcess) bProcess = (postProp != null);

                        if (bProcess)
                        {
                            // Get the value of the properties
                            string preVal = CustomDynamicEntity.GetAttributeValue(preProp, true);
                            string postVal = CustomDynamicEntity.GetAttributeValue(postProp, true);

                            // Has the property changed?
                            if (preVal != postVal)
                            {
                                i.Value ++;
                            }
                        }
                    }
                }
            }
            auditRecord.Properties["new_totalchanges"] = i;
            if (context.MessageName=="Update" && i.Value == 0) return;