I want to retrieve a report_id for the default report for an IG. I tried using apex_application_page_ir_rpt APEX view but there is no data there for that specific application. How can I programmatically find a default report ID?
Best place to start is the view APEX_DICTIONARY. For interactive grid related views, search for any names that have the string 'IG' in them (view with 'IR' reference interactive reports only).
select distinct apex_view_name from apex_dictionary where apex_view_name like '%IG%'
The logical view name that sticks out is APEX_APPLICATION_PAGE_IG_RPTS. The following query will give all available info for a saved report:
select * from APEX_APPL_PAGE_IG_RPTS WHERE page_id = <yourpageid> and application_id = <>yourappid and type = 'PRIMARY';
Related
I've created an interactive report to add/update/delete employee info records in custom db table.
My end user requirement is upon entering the employee number in the EMPNO field, all the details from the oracle standard table such as employee name, marital status, gender, bday must be auto generated in the form and they will only manually input the location name and mode of exit.
Now I created 3 pages: 1.home page, 2.add page, 3.update page
On page 1 (home page)
I have here the select SQL
with checkbox
On page 2 (add page),
In the page processing portion
I have
EventAddRecord
Source: db , plsql code
Here's my sample code:
BEGIN
INSERT INTO EMPINFOTBL
(PERSON_ID,
EMPLOYEE_NUM,
EMPLOYEE_NAME,
MARITAL_STATUS,
BDATE,
GENDER,
LOCATION_NAME,
MODE_OF_EXIT
)
VALUES
(SELECT PERSON_ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT EMPLOYEE_NUMBER ID FROM
PER_PEOPLE_X WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT FULL_NAME FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT MARITAL_STATUS FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT DATE_OF_BIRTH FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
(SELECT GENDER FROM
PER_PEOPLE WHERE EMPLOYEE_NUM = :P2_EMPLOYEE_NUM),
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
);
END;
Buttons
SAVE with dynamic action
When click add button if True submit page
Now my problem is how to do the update when I click the check box,
I want my record to be displayed in the form because currently when I click the check box the form is null
To create a new record (using Page 2), you'd create a select list item which is based on per_people table; you'd display any information you want, but you'd return employee ID:
select full_name as display_value,
employee_num as return value
from per_people
order by full_name;
After selecting desired person, enter values into P2_LOCATION_NAME and P2_MODE_OF_EXIT items. When you hit the "Save" button (which submits the page), run the process (I modified what you wrote; should be way simpler):
INSERT INTO empinfotbl (person_id,
employee_num,
employee_name,
marital_status,
bdate,
gender,
location_name,
mode_of_exit)
SELECT person_id,
employee_number,
full_name,
marital_status,
date_of_birth,
gender,
:P2_LOCATION_NAME,
:P2_MODE_OF_EXIT
FROM per_people
WHERE employee_num = :P2_EMPLOYEE_NUM;
As of updating existing values: I'd again suggest you to use the Wizard as it creates everything you need - form page is based on empinfotbl table, while "Edit" button in Interactive report sends the ID value to form page whose pre-rendering process fetches data related to employee identified by passed ID.
If you created your own page, you'll have to do it all yourself.
You said:
I want my record to be displayed in the form because currently when I click the check box the form is null
Form items are empty because Apex didn't know what to fetch. As I said: pass ID value, create pre-rendering process. Or start over with the Wizard (I prefer that option).
#Littlefoot has given a perfect answer already, here are just some extra steps that might guide you to a solution (it's the "or start over with the wizzard" piece from Littlefoot's answer). I'd suggest looking how apex generates its pages when you do it out of the box. Just for testing, follow these steps
Create a new page of type "Interactive Report" and make sure to check the "Include Form Page" attribute
Give the form page a name and select "PER_PEOPLE" as table/view name
In the 2nd page of the dialog, select the primary key column of PER_PEOPLE: person_id
Click "Create Page"
You now have a working form and report that you can further customize to your specific requirements. It should give you a good idea of how a form and a report is generally configured in APEX and it saves you a ton of time
Notices how in the report page:
The edit link has the form page as target and passes the id
The CREATE button has the form page as target without the id
In the form page
No custom code is needed to initialize the form data for the current record. Instead the native process of type "Form - Initialization" is used.
No dynamic actions are used to perform the inserts - for a form that is a bad practice. Avoid it.
No custom code is needed to perform the inserts or update. Instead the native process of type "Form - Automatic Row Processing" is used.
Study these pages and apply similar logic to your own pages. It'll be a better app.
I have a Master Detial with 2 interactive grids.
I would like to be able to genrate a link based on user input....is that at all possible?
To give a simple example:
Lets say I have website like https://www.google.com/
I would like a user to enter anything...for example "Prague"
Once this is entered, I would like APEX to generate a URL from it to result in: https://www.google.com/Prague
Now I know that Google search does not work like that, but I need that sort of mechanism for our internal company app. Is this possible?
Ideally , once the grid is saved the link in the Interactive grid only said "Prague" but if I click it, it would direct me to https://www.google.com/Prague
This can be achieved using the "JavaScript Initialization Code" attribute of the column.
Example on the EMP sample table (*). Functionality is that when a user enters a value in the ENAME column, it is converted to a google search url.
Create an editable IG on table EMP
Set the type of column ENAME to "Text Field"
Set "Javascript Initialization Code" for column "ENAME" to
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '&ENAME.'
};
return config;
}
Notice that the column now is a link. A user will have to open in new window to get the actual link value, since clicking the column will active the edit mode.
(*) Sample dataset can be installed using SQL Workshop > UTILITIES > Sample Data Sets > EMP/DEPT
yes, you can let user enter the value and by creating a dynamic action(choose the when attribute as whatever suits you) you can take that value and on another column, use that column as &Columnvalue. for example and concatanate it by using to base url using ||
How can I overcome this {Ajax call returned server error ORA-01403: no data found for} problem? Problem arises ,When I want to set Order_Status_Field value 2 in IG where query was Order_Status_Id=1.
My IG query was :
SELECT P.ORDER_ID, P.ORDER_STATUS_ID FROM ORDER_DETAILS P WHERE P.ORDER_STATUS_ID=1;
My Workspace Name: ZISHAN
User: ZISHANIIUC#GMAIL.COM
Pass: 123
Problem Page No: 3 (Order Report)
1. Before Updating Order Status:
2. After Updating Order Status:
I saw your are using standard "Interactive Grid - Automatic Row Processing (DML)" process, which is an AJAX approach. this apex behaviour is a call ajax using json format for data. so you have a filter on your sql query
SELECT T.ORDER_ID,
T.TABLE_ID,
T.TAKEN_BY,
T.ORDER_STATUS_ID,
T.TOTAL_COST
FROM ORDER_DETAILS T
WHERE T.ORDER_STATUS_ID=2
and you want to update your filter column (data has change) it's seem like apex do not find the prevouis data filter and return no_data_found (not really sure what happen ) but for solution : .
put your filter in interactive grid --> action button ---> filter
or
write your own custom process
When i tried do alter the process from the "Interactive Grid - Automatic Row Processing (DML)" that apex creats, for my own custom PL/SQL Code i needed to choose one of the columns from the query to be the primary key, and then i could use the pl/sql custom process as found here on this blog:
https://mikesmithers.wordpress.com/2019/07/23/customizing-dml-in-an-apex-interactive-grid/ without the no data found error.
I have an interactive report and a form associated to it. After creating a new entry using the form, my end-users want to put the focus on that specific new entry in the interactive report (it's a lot of entrys, and today they need to scroll down a lot to see the new one).
They also want the same funcionality when updating a row of the report.
How can I do this the correct way in APEX 5.1?
Here is one aproach based on EMP table in apex.oracle.com Create interactive report with edit form. In my case this is page 6 for report and page 7 for edit. Create one hiden item on page six (P6_EMPNO). Add case to your query so in my example it's look something like:
select "ROWID",
"EMPNO",
"ENAME",
"JOB",
"MGR",
"HIREDATE",
"SAL",
"COMM",
"DEPTNO"
from "#OWNER#"."EMP"
ORDER BY CASE WHEN EMPNO = :P6_EMPNO THEN 1 ELSE 2 END, EMPNO
I'm sorting result by EMPNO.
Choose P6_EMPNO in Page Items to Submit section. Go to page 7, select branch(Go to page 6)and click on Target In set items section choose P6_EMPNO and for target &P7_EMPNO.
Now every time you go to page 7, the value of hiden item will be the EMPNO from page 7 and it will apear on top of the region. You can use jQuery to highlight the row and put some validations to update P6_EMPNO only when some data was changed.
I hope this can help you.
easy.
You don't even have to create any additional page items. Change your form DML so that it returns into the primary key page item holder. Then Create a process after your DML process but before the reset cache process. Use APEX_IR API to reset pagination on your IR page, and then set an interactive report filter based on the primary key page item you returned the new PK into. Check the documentation for exact usage.
Apex_IR.reset_report to reset the report pagination and remove any filters.
Apex_ir.add_filter to add a filter = to new primary key
Interesting question, another solution:
Create a item in your report page, something like P3_ANCHOR
Add data-anchor="#< YOUR_COLUMN_ID >#" to your report link attribute
Configure your form page to return the created/modified item id to item P3_ANCHOR in your report page.
Create a Dynamic Action on report page
Action: Execute Javascript Code
Code:
var container = $('body'),
scrollTo = $('[data-anchor="'+$v('P3_ANCHOR')+'"]');
container.animate({
scrollTop: scrollTo.offset().top - $(document).scrollTop()
}, 2000);
Simple solution:
Sort your report descending so that the last created ID will be the first in the IR
I have created a bar chart on APEX 5.0 where my query looks like below:
select col1 as label,col2 as value from table1 where :P3_NEW_1 = col3;
here: P3_NEW_1 the page item I have created of type "Select List".
The list of values in "Select List" page item are pre-populated in the dropdown using the "Shared component" type I have created and so far this worked fine and I am able to display the results of above query by passing the value through the page item select list.
Now I need to add 2 data pickers on the same Apex page such that I should now be able to filter the results using date picker through dynamic action.
I know that using an additional button I can create a dynamic action but my problem is how do I modify the above query such that following should happen.
During the page load, once I select a particular value from the "Select List", it should display records based on the value selected from dropdown
This I already achieved using above sql query for the bar chart.
Once the bar char is displayed, I should next be able to filter and display the results using date ranges through date pickers.
Here my problem is my bar chart query is same but I need to now pass the start_date and end_date to the same above sql query which but I am not sure how to achieve this. If I add a button for dynamic action I need to select the report region which is the "bar chart" region and here my query needs modification.
Once the bar chart display the results, at the next step how do I filter the results by having the date filters with dynamic action on the same region where bar chart was displayed. How to achieve this?
You can change the query to something like this:
SELECT COL1 AS LABEL,
COL2 AS VALUE
FROM TABLE1
WHERE :P3_NEW_1 = COL3
AND (:P3_START_DATE IS NULL
OR TO_DATE(TIME_STAMP,'YYYY-MM-DD-HH24:MI:SS') BETWEEN :P3_START_DATE AND NVL(:P3_END_DATE,SYSDATE));
Where :P3_Start_date and :P3_End_date are the Start and End date pickers and TIME_STAMP is your column where you store the date.
After modifying the query you can simply add a button where at Behavior>Action select Submit Page.
This way when you click the button, the page will be submitted and chart refreshed.
If you want to take your chart to the next level you can do a partial refresh on it. Here is a short video tutorial of partial refresh on a report but you can apply the same login on your chart.