CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Redirect page based on if user sessionid is salesperson

Print topic Send  topic

Author Message
robn

Posts: 70
Posted: 07/21/2006, 7:30 AM

Hi there

I've searched the site up and down (I'm sure I have missed the resolution somewhere) the site and found plenty of information of page redirection but can't find what I'm looking for.

What I need to be able to do is from a list screen when the user selects a record to view, onclick the system checks to see if the logged in user (userid) is that records Saleperson. If they are then they get an updatable view (HBFF2A.asp) if they are not then the only get a read only view (HBFF2B.asp) along with the records ID (OID). I've tried the following code to Href Source of the link but it doesn't seem to work.

Java =

function ViewOpportunityFromList()  
{  
If (document.0pportunity.Salesperson.value ==(session("userid")))   
		e.getPage().setRedirectString("HBFF2A.asp");  
Else   
		e.getPage().setRedirectString("HBFF2B.asp");  
}

and

function ViewOpportunityFromList()  
{  
If (document.Opportunity.Salesperson.value ==(session("userid")))   
	window.location = "HBFF2A.asp";  
Else   
	window.location = "HBFF2B.asp";  
}

These both return the error "document.Opportunity.Salesperson is null or not an object". I think this may be to do with it been a list screen not a record screen?

Also when I try the following VBScript code

function ViewOpportunityFromList()  
If Salesperson.value = (session("userid")) then  
	Redirect = "HBFF2A.asp"  
else  
	Redirect = "HBFF2B.asp"  
end if  
end function

with the on click code being

VBScript:ViewOpportunityFromList(this.form.Salesperson.value)

I receive the following error message

"object required 'this'".

i'm currently developing in ASP with SQL2000

Any help on how I may achieve my requirement to load either the update form or view form based on the userid from a list screen would be much appreciated.

Many thanks in advance

Rob

View profile  Send private message
Waspman

Posts: 948
Posted: 07/22/2006, 2:50 AM

Think i'd do it another way...

I would determine the pages visible to the user having identified their type when they logged in.

So basically there would be two routes.

or. ..if they login, show links to one set of pages, if they don't show the other. I wouldn't wait till they made a request to determine whether they had logged in or not.


HTH


Tony
_________________
http://www.waspmedia.co.uk
View profile  Send private message
DonB
Posted: 07/22/2006, 9:38 AM

Think the other way around - Everyone clicks back to the same page, but YOU
change what that page displays based on the UserID. One very simply way to
do this is to have the two alternatives as Include pages placed on that
page. Now all you have to do is show one or the other, based on who they
are. Everyone sees the same page (well, the same URL) but it contains
different information for different users.

--
DonB

http://www.gotodon.com/ccbth


"robn" <robn@forum.codecharge> wrote in message
news:644c0e50807210@news.codecharge.com...
> Hi there
>
> I've searched the site up and down (I'm sure I have missed the resolution
> somewhere) the site and found plenty of information of page redirection
but
> can't find what I'm looking for.
>
> What I need to be able to do is from a list screen when the user selects a
> record to view, onclick the system checks to see if the logged in user
(userid)
> is that records Saleperson. If they are then they get an updatable view
> (HBFF2A.asp) if they are not then the only get a read only view
(HBFF2B.asp)
> along with the records ID (OID). I've tried the following code to Href
Source
> of the link but it doesn't seem to work.
>
> Java =
>
>
function ViewOpportunityFromList()  
> {  
> If (document.0pportunity.Salesperson.value ==(session("userid")))  
> e.getPage().setRedirectString("HBFF2A.asp");  
> Else  
> e.getPage().setRedirectString("HBFF2B.asp");  
> }
>
> and
>
>
function ViewOpportunityFromList()  
> {  
> If (document.Opportunity.Salesperson.value ==(session("userid")))  
> window.location = "HBFF2A.asp";  
> Else  
> window.location = "HBFF2B.asp";  
> }
>
> These both return the error "document.Opportunity.Salesperson is null or
not an
> object". I think this may be to do with it been a list screen not a record
> screen?
>
> Also when I try the following VBScript code
>
>
function ViewOpportunityFromList()  
> If Salesperson.value = (session("userid")) then  
> Redirect = "HBFF2A.asp"  
> else  
> Redirect = "HBFF2B.asp"  
> end if  
> end function
>
> with the on click code being
>
>
VBScript:ViewOpportunityFromList(this.form.Salesperson.value)
>
> I receive the following error message
>
> "object required 'this'".
>
> i'm currently developing in ASP with SQL2000
>
> Any help on how I may achieve my requirement to load either the update
form or
> view form based on the userid from a list screen would be much
appreciated.
>
> Many thanks in advance
>
> Rob
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

robn

Posts: 70
Posted: 07/24/2006, 2:51 AM

Thanks DonB

I think your idea could work any idea of the kind of code to do this? All records are visible to the user on the list screen which is the first page (the userid is set by another application and their will always be a userid) they see but when the link is selected they either see a read only view or a updateable view.

DonB is your suggestions to do a onload of the record do a redirect based on the userid?

many thanks in advance

Rob
View profile  Send private message
robn

Posts: 70
Posted: 07/24/2006, 4:30 AM

I've just tried some code that I though would work but for some reason doesn't. I set the link page from the list screen to point to s record the contained the value of the salesperson.

then on the before show event of this page I placed the following code.

Dim oid  
Dim Salesperson  
OID = CCGetParam("oid", Empty)  
Salesperson = CCGetParam("Salesperson", Empty)  
if Len(session("userid"))=Salesperson then  
response.redirect("HBFF2A.asp?OID=" & OID & "&Salesperson=" & Salesperson)  
else  
response.redirect("HBFF2C.asp?OID=" & OID & "&Salesperson=" & Salesperson)  
end if

The code runs but the if statement always points to the HBFF2C page even if the user sessionid does = the salesperson.

I've run some tests and both the SessionID and the Saleperson parameters are being pass (if I change Len(session("userid"))=1 when the userid = 1 then form HBFF2A is displayed and the same the other way round (1=salesperson)).

But for some reason when the two are run together the code does not appear to work.

Any help would be great

Rob
View profile  Send private message
Waspman

Posts: 948
Posted: 07/24/2006, 7:20 AM

I think what Don's saying is a simple if condition based on the session id.

something like
if session("UserID")=1 then
label1.value = "<!-- #INCLUDE FILE=".Option1.asp"-->
else
Label1.value = "<!-- #INCLUDE FILE="Option2.asp"-->
end if

You'd have to play with the syntax but it's that sort of thing.

Tell him what ya mean Don:-D
_________________
http://www.waspmedia.co.uk
View profile  Send private message
DonB
Posted: 07/24/2006, 6:57 PM

What I'm referring to are the "Include" page objects as defined in the CCS
ToolBox. That is, a page created with the 'Includable" attribute set to
"Yes". This creates a page 'fragment', that is only usable when inserted
into another page (which has it's Includable set to "No").

Then it is a simple matter to put Before Show event code in the 'outer'
(non-included) page, that sets the Visible property to true or false for the
Include page. The effect you get is one page with multiple visual
appearances. You can write the event code to set visible/invisible
whichever includes you want to allow a user to see.

This gets you away from 'how/where do I redirect' issues, which can be
complex and difficult to manage.

Example: The outer page has two Grid controls, one for sales, the other for
non-sales. The page's Before Show event checks the CCGetGroupID() return
value and if it's the 'sales' group, the first Grid is Visible, the second
is no Visible. If CCGetGroupID() indicates the 'non-sales' group, you
reverse this, hiding the 'sales' Grid and showing the other one.

No logic needs to be coded into your 'list screen'. A click there always
sends you to the 'view' page, only (as above), this page can show either an
updatable view or a read-only view because you have built these two Includes
and put them on the view page.

Of course, the update/no update behavior COULD simply be implemented by
toggling the data source properties InsertAllowed, UpdateAllowed and
DeleteAllowed in your particular application. Doing this means everyone
sees the exact-same page (no Includes required), only you turn off the
buttons (they have a Visible property, too!), leaving only a 'Cancel' option
visible to those not permitted to make changes.
--
DonB

http://www.gotodon.com/ccbth


"robn" <robn@forum.codecharge> wrote in message
news:644c4981bd0653@news.codecharge.com...
> Thanks DonB
>
> I think your idea could work any idea of the kind of code to do this? All
> records are visible to the user on the list screen which is the first page
(the
> userid is set by another application and their will always be a userid)
they see
> but when the link is selected they either see a read only view or a
updateable
> view.
>
> DonB is your suggestions to do a onload of the record do a redirect based
on
> the userid?
>
> many thanks in advance
>
> Rob
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Waspman

Posts: 948
Posted: 07/25/2006, 1:34 AM

Ahh,

So stick both page oprtions on the page as includes and do this...

If session("Accesslevel")=1 then
include1.visible = TRUE
include2.visible = FALSE
else
include2.visible = TRUE
include1.visible = FALSE
end if

in the before show event.

Brill.


Thanks Don;-)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
robn

Posts: 70
Posted: 07/25/2006, 3:07 AM

thanks guys for all your help so far this sounds like a great way of doing it.

But I'm having one problem for some reason the 'outer' (non-included) page does not seem to allow me to have 2 includes associated with it. When I associated two includes I receive the following error message.

Error Type:
Microsoft VBScript compilation (0x800A0411)
Name redefined
/ssso/tight/HBFF2AInclude.asp, line 139, column 6
Class clsRecordtbltightOpportunitie 'tbltightOpportunitie Class @2-20AACCBE

Do you have to place the includes some where in particular so the non-include page can reference more than one include?

many thanks

Rob
View profile  Send private message
Waspman

Posts: 948
Posted: 07/25/2006, 3:43 AM

Ya can include as many pages as ya like.

The problems casued by elements on the include pages being called the same name.


:-)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
robn

Posts: 70
Posted: 07/25/2006, 4:06 AM

thanks Waspman your right i renamed the page and now it loads thanks for your help.

I still have one problem though the parmeters in the IF statement don't seem to be working correctly. I have the following code

If session("userid")= CCGetParam("Salesperson", "") then  
HBFF2CInclude.visible = FALSE  
HBFF2AInclude.visible = TRUE  
else  
HBFF2CInclude.visible = True  
HBFF2AInclude.visible = False  
end if

Both parameters are been passed to the form but no matter if they match or not HBFF2CInclude is displaying. When I hard code either the session("userid") (say to 1) or the CCGetParam("Salesperson", "") (say to 1) the code works fine so both parameters are been picked up. But when I use the two of the together they appear to be being ignored?

and help would be much appreciated

Rob
View profile  Send private message
Waspman

Posts: 948
Posted: 07/25/2006, 4:36 AM

When I do this I set a session to a value, for example

When sales people log onto to my TOYOTA intranet I load all their relevant details and assign them to session variables.

Then when the sales person clicks on a link to load an extrernal app to book a visit to the factory or whatever.

The session variables are picked up by the visit booking app.

So in the users admin I have fields that specify whether they are a
salesperson, a buyer or a dealer principal.

They're just yes or no text fields, but when I first load the users details I load the 3 parameters.

The when the new app opens it ask the question does session("salesperson") = "Yes" and then acts accordingly.

I wouldn't be the userID, and you coiuld if you wanted it to be mega complicated do a lookup, but the easiest way is just to load the users profile and assign all their parameters to session variables. I do this with names, emails address everything.

Hope this helps;-)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
robn

Posts: 70
Posted: 07/25/2006, 6:16 AM

Thanks Waspman

I understand what you mean and its a good idea, but unfortunately in this case each record could in theory have its own salesperson (userid from 1 to say 6000) therefore when the user selects a record from the list screen they may be the owner or they may not so its at this point that I need to discover if they are the owner or not not just if they are a salesperson.

I'll keep on looking, thanks again for your help so far.

Rob
View profile  Send private message
Waspman

Posts: 948
Posted: 07/25/2006, 10:46 AM

Hey, hey!

I do the same thing in INTELLECT see showcase.

I pass the salesperson or not parameter as a session and only display the records owned by the user by setting the where conditions in the table. Easy peasy lemon...:-D


_________________
http://www.waspmedia.co.uk
View profile  Send private message
Waspman

Posts: 948
Posted: 07/25/2006, 11:14 AM

oop's

No it's not the same as the thing I do..:-P

Back to basics... so a user logs on, they select a record which goes to and editable screen if they own it and un-editable if don't (so far ok?).
So does it matter if They're a salesperson?

I do something similar with recordlist and show a link to an editable record if the own it and a normal grid if they don't.

It's just a standard grid with 2 links whos values change dependant of the users profile.

No includes, just simple if conditions based on the users profile.

I'm sorry if I've made it more confusing.

I've confused myself:-P


_________________
http://www.waspmedia.co.uk
View profile  Send private message
robn

Posts: 70
Posted: 07/26/2006, 3:29 AM

Waspman thanks again for your help I may have been missleading by using the term saleperson. The salesperson is as you quite rightly said basically the owner of the record so when the userid matches the owner id they see an updateable page and when they are not the owner they see a read only page.

I finally managed to get this working this morning!

What I have done is create a dummy page that the list sceen links to on selection of a document. This screen basically hold the ID (OID) and Salesperson (owner) values. Then added code to the before Show to redirect the user to the correct screen.

The code looks like this

if tblOpportunitie.Salesperson.value = session("userid") then  
response.redirect("HBFF2A.asp?OID=" & tblOpportunitie.OID.value & "&Salesperson=" & tblOpportunitie.Salesperson.value)  
else  
response.redirect("HBFF2C.asp?OID=" & tblOpportunitie.OID.value & "&Salesperson=" & tblOpportunitie.Salesperson.value)  
end if

Thanks again for you help

Rob
View profile  Send private message
Waspman

Posts: 948
Posted: 07/26/2006, 5:48 AM

Great!:-D

Its' easy when you know how.

I always find how a system works is more to do with its structure than the code.



Take care...Tony

_________________
http://www.waspmedia.co.uk
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.