aKzenT
aKzenT

Reputation: 7915

Branch doesn't pass item values

I have the following problem in application express which is driving me crazy:

I have a tabular form in an APEX 4.1 which includes a link column. When the user clicks the column I want to save the current state of the application and redirect him to another page. I have to pass the ID of the row in which the link was clicked to the other page.

Using Google I found this solution: https://forums.oracle.com/forums/thread.jspa?threadID=489666&tstart=720

The idea is submitting the page using a special REQUEST value and saving all the required item values in hidden page items using a javascript function called from the link. Then you create a page branch looking for the special REQUEST value as a condition and going to the desired page, setting the items in the target page to the page items in the current page that you saved before.

I followed the instructions, but it's not working. The target page gets loaded, but the items are not set.

In my javascript I put an alert displaying the value of the ID that gets passed. This works. I also changed the hidden page items of the tabular form to a text field and they get updated correctly and are persisted.

The log also shows something like this:

...Session State: Saved Item "P20_PRUEFUNG_ID_AKTIV" New Value="3950"

which looks good.

However when looking at the URL of the target page after the redirect it looks like this: f?p=110:22:1750507087114492::NO::P22_PRUEFUNG_ID:

P22_PRUEFUNG_ID is the name of the page item I want to set in the target page. Notice that there is no value transmitted for the item.

In the log of the target page I find this:

Session: Fetch session header information
Saving g_arg_names=P22_PRUEFUNG_ID and g_arg_values=
...Session State: Save "P22_PRUEFUNG_ID" - saving same value: ""

For some reason the value from page 20 doesn't get passed to page 22. Looking at my branch I can't find any error. I created a normal branch (after processing) with the following parameters:

Page: 22 Set these items: P22_PRUEFUNG_ID With these values: &P20_PRUEFUNG_ID_AKTIV. Condition: Request = EDITSG (my special request value).

I have to add that I'm still a beginner to APEX. So it's probably something stupid.

Other solutions to solve the problem described at the beginning are of course also wellcome. Bonus points for ideas how to make this work with newly inserted items (passing the id of the new item).

Edit: Here is a screenshot of the source page: Source page

There are 2 more branches in the page. The branch to page 21 is like the branch to page 22, just firing on clicking another link in the table (another REQUEST value) and also not working. I don't really know why there is a branch to page 20, which is the current page. It's something that APEX added. Maybe a relict from updating from APEX 3. In any case I disabled it setting the condition to "never", so it shouldn't influence the results(?)

Thanks!

Upvotes: 4

Views: 14153

Answers (1)

Tom
Tom

Reputation: 7028

I've gone through the steps that are mentioned in the link you posted and made 2 pages that do this kind of thing. Page 20: tabular form on emp, with a column link. This link calls a javascript function (page>javascript) which puts the selected empno in an item P20_P_EMPNO (shown on the bottom for reference).

function godetail(nEmpno){
   $("#P20_P_EMPNO").val(nEmpno);
   doSubmit("EMPDETAIL");
};

For example, when i change the commission for BLAKE to 10 and press the pencil, i get directed to page 21 where the details are shown for BLAKE. My commission is also updated.

I had to change the condition of the MRU. Standard it is bound to the submit button, you need to clear this field. Then change the condition to Request Is Contained within Expression 1, and put SUBMIT,<YOUR_REQUEST>. As described. For the branch, i put my own conditional branch first in the sequence. This is important, you don't want another branch to fire before this one. branch details

Edit: your page 20 branch is probably used for clearing the cache upon delete?

Make sure: the items referenced are spelled proper. Use caps. If you want to use an item to set a value with, use the static text substitution strings: &ITEM. (many forget to put the dot at the end at first).

So, i'm not sure why it is going wrong at your end. If you want you can take a look in my workspace at pages 20 and 21, see if you spot anything. http://apex.oracle.com/pls/apex Workspace: TOMPETRUSBE, apex_demo/demo

As for going to the details of a new record: you obviously can't pass through an id. You can not 'catch' it either, since a multi-row-update doesn't return id's anywhere, unlike with a single row DML process. Makes sense. So what you'd do instead of passing on an id, is passing on a unique key. It's obvious you need values to specify which row you wish to view, so this'll only work when you can get these. If you can only work with id, then you'd be out of luck.

You'd also need to change the DML-Fetch process on your detail page: instead of working with rowid or id, change this to your unique key values you pass along. More than 3 fields? Use a page process to select the values into your page items.

An example would be person: instead of passing on the person_id, you'd pass on the name and surname.

If however, you allow the user to enter some sort of ID or UK, then you can keep it like that. For example, if i was to allow users to enter empno for a new row in my example application, it would work! (except when the submit fails, of course)

Upvotes: 4

Related Questions