EDIT 3/16/2018: Reader Jen G. pointed out that a staff member’s staff_id != people_id in all cases and therefore my approach would not always work for all staff. She proposed a different form to copy for this setup that will work 100% of the time so I have updated the post to reflect her proposed changes and fix my approach. Thank you, Jen!
This comes from a reader request. The goal was to create a subreport in the Agency > Staff & Security > Staff Information formset that would list the service events that a selected staff member had not fully completed. The subreport could be useful for supervisors to follow up on events that their supervisees needed to e-sign or otherwise complete, especially in the event where a staff member was transitioning out of the agency. The following is my proposed solution to that problem:
Step One: Create a User Sub Report
Navigate to Setup > User Tools > Sub Reports – User > User Sub Reports and create a new User Sub Report. Give the sub report whatever name and code you wish. For System Sub Report, select any report that has
event_view as a Data Source Name. In my case, I chose the “Compass (Initial) Peer Delivered Services” report.
When you are selecting from this list, the only critical thing is the data source name. Everything else only speaks to how that particular report had been configured with the data source for that particular system report. It will tell you which columns were used to join and the remarks column will give you and idea of how it might be used “out of the box” but you can change all of those properties once you have the data source linked to your user sub report.
On your new sub report, change the following properties:
is_service_event = 1 AND is_locked = 0
This will filter the event log to only show events that are service event and only those that are not locked. The
event_view has many columns in it that will allow you to customize this filtering to get exactly what you want to see. Some other options are:
Report Fields: Pick any that you want to display. For my subreport, I wanted to show the client (
full_name), the event (
event_name), and the date of the event (
The one that you need to have for sure is
staff_id, which we will mark as a join column. In the Overwrite Form Field to Join, put some value (I used “staff”) and for the operator, choose “Equal”. Remember the Form Field to Join that you used for later. Below is a screenshot of my setup:
Step Two: Create Form
You don’t have to create a whole new form to house this subreport. You might choose to add the subreport to one of the already existing forms in the Staff Information formset. The important thing for this step is that the form you end up putting this subreport on MUST have the staff’s
staff_id on it. Maybe the form already has it on there or maybe you need to add it in the form of a variable. I will show you how to add it if it doesn’t already exist.
In my case, I am adding the subform to a custom version of the Personal Info formset member. So in form designer, under the Personal Information form family, I copied the Staff Personal Information Form. On my custom form, I hid all of the fields that I did not want users to see and I added the subreport that I created in part one. Now I need to make sure there is a staff_id named “staff” for the subreport to join on.
To do this, add a regular string variable to the form. Caption it whatever you want but give the variable name the same name as your used for your Overwrite Form Field to Join on the subreport created above. We need this variable to default in with the staff member you select’s
staff_id so in the default value field, we will put the following code:
Edit: Because I used a form from the Personal Information form family, the
keyValue in this case will be a
people_id and not a
staff_id. Therefore it will only work right on those staff who have the same value for their staff_id as they do for their people_id and this is not always the case. If you copy a form from the Staff form family, you can simply use
keyValue because it is the
staff_id. But if you are copying a Personal Information form, use the following code to get the
getDataValue('staff', 'people_id', keyValue, 'staff_id');
Here is a screenshot of my variable’s configuration:
Once you have confirmed that this field is pulling in a GUID, you can make this field invisible on the form.
Step Three: Create a New Formset Member
With your new form created, you can now associate it with a new formset member so that you can display it for users.
Navigate to Setup > User Tools > Formset Maintenance > FormSet Members and select the Staff Information Formset from the Agency module.
Create a new formset member, name it what you’d like and then select the Personal Information form Family and your new form as the Default Form. Make sure Is Active is checked and then save. Remember to go through the Navigation scheme setup and turn on the new formset for the users who will need access.
The Final Product
With everything setup above, you can navigate to your new formset member and select a staff member. Your form variable should get a default value of the staff you selected’s
staff_id and your sub report should be joining on the that
staff_id, thereby filtering the
event_view to that staff member’s events. Your SQL Code statement on the user sub report will further filter the event_view to just those you are interested in seeing. In our case, the service events that are not locked.