I have an Invoice object which has an InvoiceType. Now, by looking at this situation, InvoiceType can exist without invoice. Should i treat Invoice as one aggregate root, and InvoiceType as another aggregate root within it's aggregate, and connect those to via ID reference, or InvoiceType should just be an entity within Invoice aggregate?
Also, when creating invoice, user must be able to choose Invoice Type from dropdown, which suggests me that it should have it's own repository.
Am I right to treat InvoiceType as separate aggregate?
Am I right to treat InvoiceType as separate aggregate?
If InvoiceType is an entity, and if two different Invoices can have "the same" invoice type, then yes - you need to treat InvoiceType as a separate aggregate, with its own repository, and connect them via ID reference.
Related
I am trying to build a Pipeline which queries out my Sales records (as one Read activity)
Now in this Sales schema there are fields that reference a People table however its not a direct connection as there is a Many-to-Many relationship.
So what I need to do is query my PeopleToSales table for all related records and populate them in a flat structure in my subsequent JSON object.
How can I built two objects together and join them based on Sales ID? Also in the event there are multiple matches how can I choose the first one?
You can read both the Sales records and the PeopleToSales table and then use the Join snap to merge the relevant documents based on whatever ID that defines the relation between them.
After that, you can use the Group By Fields snap to group the documents based on Sales ID.
You can add the Sales ID field (say - $sales_id) in the Fields list in the settings and it will group documents based on the Sales ID.
Also, when using the Group By Fields snap, you first have to sort the documents based on the keys. So, use a Sort snap before the Group By Fields snap.
As far as getting the first object is concerned, after the group-by, you can just get the 0th element of the list (say group[0]).
Please refer to - SnapLogic Docs - Group By Fields
In my customer record, I have a field called Membership Status. So the membership will change from Regular member to Prime member once a member purchase a particular item. Is there any way to update the field after the Invoice creation?
Thanks in advance!
Yes. Use an afterSubmit() event on a User Event script deployed on the invoice record. Search the invoice item lines for the item, and if found use record.submitFields(options) to update the field on the customer record.
If you are making other changes to the customer, you could use record.load(options) to load the whole record instead and then use the Record Object Methods to modify and save the record.
For updating a small number of body fields, submitFields() will usually be more performant, but if you need to manipulate sublists or subrecords, you need to load the record.
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>" +
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
I'm following Apple's documentation about Relationships. In their example, a Department has a to-many relationship to the Employees that work in a Department, and there is an inverse relationship from an Employee to the Department.
What should be the delete rule from Employee to Department? When I delete an employee, I don't want to change anything in the department, so the rule would be "No Action", which gives me a warning. I suppose I'm missing something here.
Nullify, which means that if a department is deleted the relationship on the Employee site will be set to nil.