APEX_ITEM displays only one row - oracle

I have created a form region "Form on a SQL query" with this query
SELECT
APEX_ITEM.TEXT(1,TEAM_MEMBER) TEAM_MEMBER,
APEX_ITEM.TEXT(2,HOURS) HOURS
FROM APEX_TEAM_MASTER
WHERE TEAM_DATE = :P2_TEAM_DATE
AND UPPER(TEAM_LEAD) = UPPER(:P2_TEAM_LEAD)
ORDER BY 1
TEAM_MEMBER and HOURS are the exact columns in the APEX_TEAM_MASTER table
The :P2_TEAM_DATE and :P2_TEAM_LEAD are select lists. When i run the page and select values in the lists, the form displays just one row of text boxes.
The purpose of this page is, a manager can login to this application, select a date and a team lead under him, which lists the members under the lead. He can then record the hours each team member worked for the day. There are multiple team leads under each manager and different number of team members under each team lead. So the form has to be dynamic.

What you described looks more like an Interactive Grid (IG) (or former Tabular Form). There's no need for you to reinvent that functionality, so - switch to the IG and let Apex take care about everything else.

Related

Model-driven PowerApp: Best practice to display subgrid of records with no appropriate primary column name

Background
Each Dataverse table contains a primary name column. When displayed in a subgrid, clicking on the primary name column will navigate to the form so that the user can edit that row. Most subgrids in my application work this way.
The Problem
I have a Course form with a list of participants displayed in a subgrid. The subgrid displays each student's name (as a link) and the grade received in the course. There is no appropriate primary name column for this Participant table. To edit the participant record, the user must select the row in the subgrid, then click the subgrid's Edit button. As a result, this UI is different from all other subgrids in the application and I know that user's will click the student name to try to edit the participant record and be confused when they are presented with the student record.
Am I missing something? Is there a better way to handle this?
It's a common problem I face quite often. Here is usually what I would do.
Make sure the Primary Name Column always contains relevant information to the user to be able to quickly identify a record. Sometimes it requires copying information from one or multiple other columns into the primary column.
In your case that would probably means concatenating the student's name and grade.
How to do that?
Common to all solutions below
Use one of the following solution to copy the content of one or several fields into the primary column.
Make sure the solution you select also updates the content of the primary name column when one of the copied field is updated.
Remove or hide the primary column from the form, the name of the record will be displayed at the top of the form anyway and you probably don't want users to play with it.
Display the primary name column in every subgrid.
I would recommend not adding the fields copied into the primary column in the subgrids to avoid confusion.
Solution 1 - Classic Workflow
Create a classic workflow that runs when a record is created / updated
Pros:
Very quick to put in place
Runs synchronously (users will see the name updated in real-time)
Cons:
Not very practical if you need to add business logic (using different fields as source depending on a certain condition for example)
Solution 2 - Power Automate
Create a Flow that runs when a record is created / updated
Pros:
You can implement complex business logic in your Flow
Cons:
Runs asynchronously (users will have to refresh the page after the creation of a record to see the record's name)
According to Power Automate licensing that flow would certainly be considered as an "enterprise flow" and you are supposed to pay 100$ / month. That specific point must be taken with a grain of salt. I had several discussions with Microsoft about it and they haven't given me a clear answer about what would be considered an enterprise flow.
Solution 3 - Plugin
Create a plugin that executes when a record is created / updated
Pros:
You can implement very complex business logic in your Flow
It can run synchronously
Cons:
Pro-code (I put it as a con since Model-Driven App is a low-code / no-code approach but there is nothing wrong about pro-code per say)
Developing a new plugin for each entity where you need this logic is kind of overkill in my opinion. I would consider developing something very generic that would only require some sort of configuration when the logic needs to be applied to a new table.

Page break the data but keep the groups on the same page

I am grouping the data in my table by person and term. I am trying to separate term groupings but keep them on the same page and have only one person per page. This image shows how it looks in Crystal Reports. The only issue I am having with SSRS is that it is putting each term group on a new page.
Crystal Reports output
Design View
Without seeing the report design it's hard to say but I would guess you have a row group that groups by both person and term with a page break set between the group.
You need two separate row groups, the inner one by term and the outer one by person, then only have page breaks on the outer group.
If this does not help, show your report design including row groups and their properties

Cognos Report-need 2nd (Totals) Crosstab that is "aware" (filters) using the current Grouping

I am trying to create a report which groups on a column called "Legal Entity." When the output is directed to Excel, a separate tab will be created for each distinct entity in the query resultset.
For each Excel tab/Legal Entity, there will be two "sections." The first is a repeating section that breaks on a column "Funding Arrangement Type." After all of the Funding Arrangement Types are exhausted, there will be a single "Totals" grid which will summarize the data on the tab for the current Legal Entity. The data will be summarized across all Funding Arrangement Types within the current Legal Entity.
Because the Totals (lower) grid is really just a summarization of the same source query, Query1, I thought that I would also bind the Totals grid to it. However, if I do that, I get a run time error that tells me that I need to establish a Master-Detail relationship (If I decide to use a separate query for the Totals grid, the Totals grid "will not be aware" of the current Legal Entity/tab that must be considered when summarizing.)
Therefore, I continued with my guess at how the Master-Detail relationship should be defined. I made various attempts to link the two grids, including:
On all of the dimension (non-summarized) columns.
On Legal Entity
On Legal Entity and Funding Arrangement Type
Doing so affected previously correct totals reported in the upper cross tab results/
This Master-Detail approach is foreign and as a result I don't understand what it is doing.
I also tried to use a separate query, Query2, for the lower totals grid and adding a filter to filter SQL2 where SQL2. LegalEntity = SQL1.LegalEntity in an effort to get the totals grid to summarize within the current LeglEntity grouping. This resulted in a cross join error.
I’m a real noob with Cognos. Suggestions are welcomed. Thank you!
You can use mouse+scroll wheel to zoom in:
I was able to get it working by binding both grids to a single query and for both grids, establish a Master-Detail Replationship on Legal Entity. Prior to doing that, I added these columns to both grids and hide them, not sure if this was necessary.

Creating a page to show data with foreign keys

I'm creating an APEX application that allows students to apply to job placements, and allows an admin to see all interactions. I want to create a page to show all of the students applications.
First off, here's the database schema for the tables involved:
Full sized link: http://i.stack.imgur.com/QU1Pr.png
I have a report with a list of students and I've added a "View Applications" column. I've made the "View Applications" column linkable, and it goes to the new page. The problem is, I have no idea how to show all of the applications for the student that the admin is currently looking up.
The only way I can think of doing it is passing RECORD_NUMBER (PK in students table) to the new page and then executing some SQL using that, and populating the page fields with what's returned. But I have no idea how to do that. I don't know how to grab the RECORD_NUMBER value to use in SQL and I don't know how to populate form fields with what's returned by the SQL.
Any help is appreciated.
So you've got one page that lists applications and the students that have applied. We'll call that page 1. If I understand what you're trying to do, you can create a page 2, with a report and a hidden page item. Call the page item P2_RECORD_NUMBER.
Create the report with the query:
SELECT *
FROM tbl_jobs j
INNER JOIN tbl_applications a on a.job_id = j.id
INNER JOIN tbl_students s ON s.record_number = j.record_number
WHERE s.record_number = :P2_RECORD_NUMBER
Now edit the link on page 1 so it points to page 2 and populates P2_RECORD_NUMBER with the record_number of the row that the user clicked on. I don't have Apex in front of me, but I think you can do that by editing the report attributes for that column. Also, you can use the url of the form http://site.com/f?p=<APP_ID>:<PAGE_ID>:0::::P2_RECORD_NUMBER:<record_number>. (I'm doing that from memory and may have the number of colons wrong.)
You'll also want to have some default text in place in case the query above returns no rows.
Just create a new page for the admin and enter a query like
SELECT *
FROM tbl_students s
JOIN tbl_applications a USING (record_number)
JOIN tbl_jobs j ON a.job_id = j.id
Do you know where to add the query?

Surely Salesforce supports regular old grouping and summarization in reports?

So the reporting system in Salesforce is a bit restricting. It seems there is no editor for an xml or other markup language to create reports in; apart from formulas you're stuck in the website drag and drop ui.
There seems to be 3 types of reports in Salesforce Tabular, Summary and Matrix. The first kind is kind of useless for more advanced reports, since it doesn't support forumulas (if both fields are in the same table you can work around this with calculated fields). However with all 3 I've found it difficult to impossible to make a report with basic details and summarized figures.
An example:
I've added a custom field "company size" to the Account table/object. This tracks the approximate number of employees working at the customers company (ever taken one of those surveys that asked you for a range of how many employees worked in your organization). I then have a custom table/object for sales, listing the account, the date and the volume ($).
I would think it would be a simple to create spreadsheet style report with each row listing an account, which state it was based in, how many employees they had, followed by their total sales and sales/employee (a formula of volume/employees).
But the grouping and summarization options don't seem to work that way. Grouping in both the Summary and Matrix report types seems to want to treat each grouped field as a seperate level, so with the 3 fields related to the account I get 3 cascading fields in a stair like arrangement, instead of being able to put them on one row.
It gets worse with the summarization - no matter what I and other colleague have tried the summarization doesn't seem to work. If an account has 50 sales we end up with 50 rows, even if we click the little arrow beside the column, click summarize and check Sum.
From an SQL perspective this report seems like something you would teach students in the first week, yet its really not obvious how translate this into something Salesforce can understand. A lot of the web ui is not discoverable (dragging fields provides no feedback as to why it can't be dropped in a particular place, some options are hidden unless you hover the mouse over the right place) so I would not be surprised if I've missed a crucial step.
So, is there an option to make this work (particularly getting sales to be totaled as a single cell for each account, not 2 or 5 or 50), maybe a distict checkbox lurking behind an innocent blank area?
Given the lack of calculated fields in the report, you need to create the formula at the object level. If it's not useful in the detail page, don't include it in the page layout. It will still be available in reporting.
The summarization/grouping options work as in SQL, but you can only group by one field at a time.
However, the result view in "show details" mode is not like a simple SQL query - more like using windowing functions where the result output can contain both groupings with aggregations at those levels, and the detail rows that fed into that grouping.
In "hide details" mode, the detail rows are not shown, and so only grouping levels and the aggregates are shown.
So, it looks like you can either:
group by state, then account, sum your employees, sum sales, and then a Custom Summary formula of sum:sales/sum:employees
or
create a formula field on account to do sales/employees
tabular report with fields of: account, state, employees, sales, your new field.
Also, if you want an XML editor, you can edit the XML for reports (as with many other parts of salesforce setup) via the metadata API and the force.com plugin for eclipse. But it's mainly for tweaking reports, or version control, or mass-actions, as there is no preview/run operations, it's mostly a metadata management system.

Resources