Hi this is my first spin with active admin, I have the two models:
Patient
Attributes
Where a Patient has_many Attributes
I created a patient resource like this:
rails g active_admin:resource patient
It seemed to work fine, however: the query active admin is creating:
Patient Load (0.9ms) SELECT "patient".* FROM "patient" ORDER BY "patient"."id" desc LIMIT 30 OFFSET 0
Attribute Load (1878.2ms) SELECT "attributes".* FROM "attributes"
The problem is with the second one, because I have about 200 000 Attributes so SELECT * "attributes" is killing my computer.
I've been looking for an hour on how to limit the second query. Any help is appreciated. Thanks.
So I figured out why the query tried to select all of the attributes.
ActiveAdmin tries to create a filter area, by default and retrieves all possibilities for the belongs_to association in order to create a drop down.
To get around this I wrote a custom filter which excludes the attribute like:
filter :name
Related
I need help for creating a report in SAP Hybris which essentially would be used for fetching out the names of "Employees" not "Customers" based on the "User Group" they're assigned. For example : X employee has usergroup : "admingroup". Like that I would need all the Employees with the respective usergroups. Could anyone please help me with a flexisearch query for the same to start with ? I would really appreciate that ! Thank you
I am still new to SAP Hybris and I have seen a lot of other reports but wanted to try this out.
You can use the string_agg()-method to list up the user groups, it's mentioned here: How to concatenate multiple rows in flexibleSearch query in Hybris
If the method doesn't work you can try to replace it with group_concat.
You also need to join the Employee with the PrincipalGroup. You can access the employee's user groups with the attribute groups:
SELECT
{e:displayName},
string_agg({g:locName}, ', ') AS groupNames
FROM {Employee AS e}
JOIN {Employee.groups AS g} ON {g:pk} = {e:pk}
GROUP BY {e:pk}, {e:displayName}
for this report it require join with PrincipalGroupRelation as there is no direct relation with usergroup and employee.
select {user_group:uid},{user_group:locname[en]},{emp.uid},{emp.name} from {Employee as emp JOIN PrincipalGroupRelation as group_rel ON
{group_rel:source}={emp:pk} JOIN UserGroup as user_group ON {user_group:pk}={group_rel:target} } where {user_group.uid}='customersupportagentgroup'
In MS Access 2010, I have two tables - one with Candidates and one with Package Actions. The Actions are associated with the Candidates via the CandidateID field, which is an autonumber in the Candidates table. The Actions table has a date field for each action. I have a field in the Candidates field that I would like to display the action type of the most recent action associated with that particular candidate, but can't seem to figure out how to do it. I've tried implementing a subquery as a default value:
SELECT TOP 1 ActionT.ActionType FROM ActionT WHERE
(((ActionT.CandidateID)=13))
ORDER BY ActionT.DateCompleted DESC;
Obviously, this query on its own only returns the most recent action for candidate 13 but ideally I would like to replace the =13 with =CandidateID but I can't even get the field to populate with the result of the query as is. I've also tried using DLookup but got an error while trying to make that the default value. I've also tried using the button "Modify Lookups", pasting the query and the DLookup directly into the cell, and trying to change the type of the field from "Text" to "Calculated", all to no avail.
Novice MS Access user here, so I appreciate any extra explanations y'all may have.
Thanks In Advance.
EDIT:
Just to be clear, I'm not looking for a query, per se. I want to know how I can make the result of my query above always be the value of a field in the candidate table. (If my code above needs corrections, I'm open to that, but that isn't really my question.)
Example: Candidate A has several actions in theActionTable associated with him. They are ResumeRecieved, ResumeReviewed, and Interviewed. The date associated with Interviewed is the most recent, therefore in the CandidateTable, the status for Candidate A should be "Interviewed." We then decide to extend an offer, so we add an action to the ActionTable "OfferExtended."
The Status field in the CandidateTable for Candidate A should automaticaaly update to read "OfferExtended"
Inside your main SELECT STATEMENT, you need to have a nested SELECT STATEMENT descendingly ordered by DateCompleted to get the most recent DateCompleted for each CondidateId.
Below should do the trick for you:
SELECT con.Id,
con.Name,
(SELECT TOP 1 ActionType FROM ActionT
WHERE CandidateId = con.Id ORDER BY DateCompleted DESC) AS ActionType
FROM Candidates AS con
I have created a custom screen that records a "SalesPerson" ID that links back to the Salespersons records.
One of the requirements is to create an inquiry screen (not generic inquiry) that has a filter for the current sales person (based on logged in user). The Filters should be "All Records" / "My Items" with the second being the default displayed (based on the recorded "Sales Person)
For this, The PXSelect statement links {customtable} -> {employee} (where salesperson record = employee.salesperson
I even extended that to link employee.userId -> users.pKid.
The actual select statement is below:
public PXSelectJoin<CWAItem,
LeftJoin<EPEmployee,On<CWAItem.salesPersonID,Equal<EPEmployee.salesPersonID>>,
LeftJoin<Users, On<Users.pKID,Equal<EPEmployee.userID>>>>> MobileOrders;
Both of these correctly display the user name in the grid however when i create a filter where EPEmployee__UserID = #me or Users.UserName = #me no records are returned.
Scanning through the system this appears to be used on the "WZ201500" screen that has a simular filter. The difference that I see is this is referencing "EPEmployee_UserId" based on the table definition.
Is there a limitation to using child DAC's and the #me or is there a different way to handle the joins so the #me works correctly?
Any assistance would be appreciated.
Having not used #me I am not sure what this refers to, however we did something similar limiting records based on the current user ID using access info like such:
Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>
Hope that helps
Just use the Table AccessInfo then Default Value of your Filter Equals to AccessInfo.UserID to any of the Table Field you need like CreatedByID or ModifiedByID
I am running into an issue when adding a new field to an entity. In my entity I had 526 fields, I tried to add a new one but I got the error message "Attribute xxx cannot be created because we have hit a maximum number of attributes allowed for an entity (1000)". However I only have 526 fields in the entity. Furthermore, I deleted one field I don't need anymore and I tried to add my new field but I still have the same error message even though I've deleted one field. Could anyone help me out please. I do appreciate it. Thanks !
Walloud
You will be hitting the column limit, even with only 526 fields.
You have to remember that CRM will add its own fields in addition to the ones that you have, such as ones for base currency. This can take you over the limit.
Also consider that the Filtered Views that CRM automatically creates have extra columns for lookup (name), optionset (name) and date (local) fields which can also mean you exceed the limit there.
I think your only options are to delete more fields in order to free up the room, or re-architect your entity design to split it over multiple related entities instead
Looks like you are facing the SQL Server 8k row limit
you can check the field names and verify this.
more information here:
http://mileyja.blogspot.com/2013/09/dealing-with-8k-sql-server-row-limits.html
You need to remember that some fields, such as currency will have two separate fields in SQL thus increment the column count by two for each one you create. If you have 500+ fields on a single entity then it is time to normalize the data and start breaking it out into related entities. It will be better for performance and your data in the long run.
http://en.wikipedia.org/wiki/Database_normalization
Cheers!
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