PDA

View Full Version : saving a session variable in a link


ABC123

Sarah Mengesha
11-29-2004, 09:07 AM
Hi All,

Does any one know how, if possible, to save as a session variable the value of a linked field a user clicks on in a grid component?

For example, I have a grid component based on a table with two fields, f_a and f_b. I have made f_a a linked field that when clicked on will redirect to a page with a filter set to the value of the selected f_a. All is fine up till here.

My problem arises when I want to continue through many pages containing grid components using the same filter expression as when the user clicked on the link for f_a field in the original table. Of course, there are fields with the same value as f_a in all the other tables I am trying to filter on.

So, is there any way to save in a session variable the actual value of the linked field the user clicks on in the first table?

Thanks in advance,

Sarah Mengesha

Selwyn Rabins
11-29-2004, 10:53 AM
if you look at example 1.10 in the sample app, you will see that the link is defined as:

CustomerFormEditable_2.A5W?cust_filter=customer_id="{Customer_Id2}"

if you change the link definition to this:

CustomerFormEditable_2.A5W?cust_filter=customer_id="{Customer_Id2}"&session.myvar={Customer_Id2}


then, when the user clicks on the link, in addition to taking them to the correct page, a session variable called myvar will be created and it will be equal to the value of {customer_id2} for that row.

Sarah Mengesha
11-29-2004, 12:26 PM
Selwyn,

I tried to save the session variable this way, but it is not being saved when the page is redirected, so my filter doesn't work through the rest of the site.

Here is the exact link I am using in the first page:

Showsubscriber.A5w?edit_sub_filter=Acct_Id={Acct_Id}&session.CurrentSubAcct={Acct_Id}

I'm not using quotes since this is a number field.

Any other suggestions why it doesn't work?

Thanksomuch,

Sarah

Selwyn Rabins
11-30-2004, 04:09 AM
it looks like the reason that it is not working is that the period in session.currentsubacct is getting URL encoded by the grid component.

you can still achieve what you want by doing this:

Showsubscriber.A5w?edit_sub_filter=Acct_Id={Acct_Id}&CurrentSubAcct={Acct_Id}

when the target page (showsubscriber.a5w) is show, there will be a local page variable called 'currentsubacct'.

on that page you can put this xbasic code block.

if eval_valid("currentsubacct") then
session.currentsubacct = currentsubacct
end if

Selwyn Rabins
11-30-2004, 04:09 AM
the above url should have been

Showsubscriber.A5w?edit_sub_filter=Acct_Id={Acct_Id}&CurrentSubAcct={Acct_Id}

Sarah Mengesha
11-30-2004, 06:11 AM
Selwyn,

That did the trick! I know its your job, but thanks for your quick responses and great explanations. :)

Thanks again,

Sarah

Selwyn Rabins
12-01-2004, 07:09 PM
if have just changed the way that computed links in the grid are URL encoded so that in the next build, if you link has session.varname={fieldname}, it will work as expected.

there will be no need for the work around described earlier in this thread.