CRM 2011 How to select the related entity fields in Advanced Find - dynamics-crm-2011

I am using CRM 2011 Advanced Find on Account Entity to find the Incident CreatedOn Date where Incident is connected to Account.
But when I go to Edit columns it does not give me option to select the Incident CreatedOn Date (Because Advanced find query is on Account Entity). Is there any way to select the Related Entity fields on in search.

You wont be able to add the Incident.CreateOn in the Edit Column from the Account entity as you can only add lookup fields (resulted from a N:1 relationship between account and the other entity).
As the Account and Incident have a 1:N relationship, you should be able to add the account column to the Incident columns as stated by Pedro Azevedo. The image below shows you how to do it:
Notice that the Record Type will show you a list of the lookup fields you have in the Incident entity and to which entity is relates to - in this case, Customer is the relationship name in the Incident entity and Account is the related entity.
Cheers, dimamura

Try do this in Incident Entity. You can filter and add columns in both entity.

Related

Link Employee to User in API

Using version 21.210. I am able to create a user via the Contract-Based REST api and I am able to create an employee. How can I link the employee to the user? So, I want to do the equivalent of selecting a "Linked Entity" on the Users screen (SM201010).
I see a ContactID field in the Employee/ContactInfo entity but, it doesn't appear to be mapped to anything. Also, it doesn't show on the entity when I query any employee using a GET and $Expand. I'm thinking that I could use the ContactID from the Employee to plug into the "LinkedEntity" field on the User.
Any thoughts would be great.
TIA!
It is linked by the UserID field on the Contact record(that is linked to the Employee via the Employee.DefContactID field). Users.ContactID is a virtual field but in the RowSelecting event it is populated by selecting a contact record where Contact.UserID is equal to Users.PKID.
So you would need to set the UserID field on the employee's Contact record to the user's PKID value. In addition there is also Employee.UserID that you would want to set equal to the Users.PKID value. The virtual field is populated using that Contact.UserID value but in the RowUpdating handler Acumatica is updating both the Contact and Employee records when Users.ContactID is changed.

Dynamics CRM 2011 SQL MetadataSchema Primary Name Attribute

I am trying to create a custom Audit summary report based on a date range that needs to be emailed nightly. I've got most of it working, but need some help with getting the primary name/field/attribute for a referenced entity. I noticed in the Audit view for a referenced entity, the data is stored like 'systemuser;'. What I would like to do is grab the Primary Field (Primary Name, Primary Attribute, whatever it's called) to display on the report. Does anyone know how to find the Primary Name attribute for an entity using the MetadataSchema views in the CRM SQL database? I have found the Primary Key field by looking at the MetadataSchema.Attribute.IsPKAttribute field, but I don't see anything for the Primary Name field.
Also, I am grabbing the current values from the entities if there are no following audit entries. For the lookup fields (like owner or customer) how can I tell from the Metadata what field stores the ObjectTypeCode? For example, if I was looking up the customer on a sales order, I know I can look at CustomerIdType field to find the ObjectTypeCode, but I need to find that the field is called CustomerIdType from the metadata.
If anyone has any good references on the Metadata from the SQL side of CRM, I would greatly appreciate it.
SQL query to get primary fields for all entities
SELECT e.Name as 'entity', a.Name as 'primary field'
FROM [dbo].EntityView e
left join [dbo].AttributeView a on e.EntityId = a.EntityId
where (a.DisplayMask & 256) > 0 --256 is for primary field
order by e.name
There are two cases to get object type code of lookup
append Type to field name (i.e. CustomerIdType)
if above is not available, get it from AttributeMetadata
SELECT ReferencedEntityObjectTypeCode
FROM [Discworld_MSCRM].[dbo].[AttributeView]
where name = '<field name>' and entityid = '<entity id>'
I'm not sure what exact rules are for Type fields to exist

Is it possible to query N:N relationships in a Dialog Query CRM Data step?

I have a custom entity called Department with a N:N relationship with the User entity. I have a lookup field on the Case entity for Department. I added some javascript to the onChange event of the Department field that will query the Department entity and get the users associated with it. If there is only 1 user it sets the Assigned To field on the case to that user. If there are more than one it kicks off a dialog that lets the user select which of the users associated with the Department that the case should be assigned to.
In the Dialog I'm using a Query CRM Data step to get the Users associated with a department but I can't figure out how. I thought with the N:N there would be an entry in the Related section when building the query. There are entries for Departments but they are for Created By, Modified By, and Owning User. Is it possible? Is there a better way to do what I'm trying to do?
You need to use a SOAP call to retrieve all the Users associated with Department. For every N:N relationship there will be an Intersect entity and you need to identify that intersect entity name from N:N relationship in System Customization as in below fig. Here I'm retrieving all the Teams associated with User. In the same way you can retrieve the Users by passing Department Id.
Note: Replace " <q1:Operator>EqualUserId</q1:Operator>" + with below code
" <q1:Operator>Equal</q1:Operator>" +
"<q1:Values>" +
"<q1:Value xsi:type=\"xsd:string\">" + _departmentId + "</q1:Value>" +
"</q1:Values>" +

Create custom view with multiple entities in CRM 2011?

I'm new in CRM 2011. So not familiar with all it functionality.
Have a question about displaying data from multiple related entities.
First Entity is a Users (contain information about user)
Second Entity is a Class (contain information about class user enrolled)
Third Entity is a Class Attendance (contain information if user attended class on specific date)
The idea is to show view with users who is enrolled in class.
To show start end dates and if user attended class or not.
Administrator should select user and change status to attended or not.
How it can be done in CRM 2011? Is it required custom development or just to View Customization using user interface in CRM?
Any suggestion or examples highly appreciated.
In Mscrm you can create a view for a single primary record type, on this view you can show fields from the primary record. You can also include secondary records that are linked via a lookup to the primary record, you can show columns of these secondary linked records. The limitation here is that you cannot link tertiary records from these secondary linked entities. The slight confusion here is that you can show the name of the tertiary entity as its a field on the secondary entity.
So to put this into the context for a real example, take the following entity model.
Contact has a 1 to Many relationship with incident (a contact can have many incidents, each incident has a lookup to contact)
Incident has a 1 to Many relationship with task (an incident can have many tasks, each task has a lookup to an incident)
So a view of tasks can;
Show all the fields from the task (task in the primary)
Show all the fields from the incident (incident is the secondary)
Show the name of a the contact, but not any other field (contact is a tertiary, but its name is shown as a field from the incident)
This is one of those things that becomes a lot clearer when you actually try it out for yourself. Its hard to say what you will be able to achieve because its not clear what your entity model is.
In any case here is how you create your own custom view.
CRM > Settings > Solutions > Your Solution > Your Entity > Views > New. There are various buttons would should hopefully be self explanatory.
Click Add Columns and it will present you with fields of the primary entity, use the Record Type drop down option to select fields from linked secondary entities.
Reading between the lines you have:
Class entity with many:many relationship to student (user), so a user can be enrolled on more than one class and a class has more than one user.
There is then a second entity for attendance which by the sound of it has a many:1 relationship to both student and class, and has a status to show attendance for a particular instance of the class on one date.
So far sounds like a good model.
Using the ideas in James' answer you ought to be doing a view of Attendances, including the name of the class and user. You might also have extra columns from the user or class to show things like when the course starts and ends, what the student's email address is etc.
Sort this view by class, then student, then attendance date and you have a pretty good view. But this won't display in any kind of hierarchy or show summaries. You might want to look at building a custom report for this instead so you can report on attendances, grouped by student and grouped by class. If you get clever you could also add filters for dates so you can look at attendances last month only, for example. You can probably do a lot of this with the built-in report wizard, for more complex or pretty versions go to SSRS

How to reuse the Entity Field in CRM 2011

I created an entity name is Student,
In that entity I created fields like Name , Age, Qualification etc.,
I wanted to add new field that is Contact number but I don't want to create new one.
Is there any chance to reuse the Mobile phone filed that is presented in Contact Entity..
If there how..??
Please help me..!!
No, you cannot move the mobile phone field from the Contact entity to the Student entity.
You will have to make a new field on the Student and hide the field on the Contact.
Or you could, add a lookup on your student to contact, so each student has a contact record associated and use the phone number that way.
Or you could, get rid of the student entity and just use the contact with the extra fields you needs, as a student is effectively a person which is effectively a contact.
The choice relies on your business requirements.
Yes, you can.
You need to create a htm webresource and retrieve the contact number in the webresource, and then insert this htm webresource into the form.
Please see this article for details:
http://www.gapconsulting.co.uk/DesktopModules/SunBlog/Handlers/Print.aspx?entryid=58

Resources