I have an IR with form and I want to create a new record as a copy of the edited one by a new COPY button.
I set the behavior of this button to redirect to the same page and set all the needed fields as the same as the original (f.e. :P7_SUBJECT to &P7_SUBJECT. , etc.).
There are some LOVs on this form. Some of the LOV-based fields were set correctly, but others didn't (they get the first value of the LOV). I don't find why, and how could set them the right value.
CodePudding user response:
If "IG" means "Interactive Grid", then I'd suggest you to use what Apex already offers (instead of reinventing the wheel):
select Interactive Grid's column (either one by one, or all of them at once)
navigate to their properties on the right-hand side of the screen
scroll down to "Default" section
set Duplicate copies existing value property ON
- Help says:
Specify whether the column should be defaulted to the existing column value when duplicating the record.
finally, run the page and
[EDIT] Interactive Report isn't exactly an Interactive Grid ...
Anyway, another suggestion:
you have an interactive report
there's the "Edit" icon at the beginning of every row - it lets you edit current values by redirecting to a form - use it
modify the form page by adding the "Copy" button
- is that what you were saying in the question?
create a page process which will perform that copying operation
how? There's the primary key column, let's call it
P7_ID
; suppose it is set to some sequence's value. Then you'dinsert into the_table (id, name, subject) select seq.nextval, name, subject from the_table where id = :P7_ID;
In other words, copy row that exists in the database and is identified by
P7_ID
. That option doesn't suffer from any screen values issues
CodePudding user response:
Here is how to open the copied record without saving the data to the database first. Example has form and report (interactive report) on the sample emp/dept data. Page 4 is the report and page 5 is the form.
- On page 5 add a new hidden item P5_COPY_FROM
- On page 4 add a "copy" column to the report that links to page 5 and sets P5_COPY_FROM to column value #EMPNO#
- On page 5 add a process before the process "Initialize Form Employee" of type "Execute code" with source
:P5_EMPNO := :P5_COPY_FROM;
- On page 5 add a process after the process "Initialize Form Employee" of type "Execute code" with source
:P5_EMPNO := NULL;
This will cause the form to initialize with row you want to copy from, but since the primary key value is reset to NULL, a new record will be created on save.