i trying create custom audit summary report based on date range needs emailed nightly. i've got of working, need getting primary name/field/attribute referenced entity. noticed in audit view referenced entity, data stored 'systemuser;'. grab primary field (primary name, primary attribute, whatever it's called) display on report. know how find primary name attribute entity using metadataschema views in crm sql database? have found primary key field looking @ metadataschema.attribute.ispkattribute field, don't see primary name field.
also, grabbing current values entities if there no following audit entries. lookup fields (like owner or customer) how can tell metadata field stores objecttypecode? example, if looking customer on sales order, know can @ customeridtype field find objecttypecode, need find field called customeridtype metadata.
if has references on metadata sql side of crm, appreciate it.
sql query primary fields entities
select e.name 'entity', a.name 'primary field' [dbo].entityview e left join [dbo].attributeview on e.entityid = a.entityid (a.displaymask & 256) > 0 --256 primary field order e.namethere 2 cases object type code of lookup
- append
typefield name (i.e. customeridtype) if above not available, attributemetadata
select referencedentityobjecttypecode [discworld_mscrm].[dbo].[attributeview] name = '<field name>' , entityid = '<entity id>'
i'm not sure exact rules type fields exist
- append
Comments
Post a Comment