close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Userid inserts into different user table fields

Thread began 8/20/2012 5:35 am by sfj6167 | Last modified 8/22/2012 9:56 am by CraigR | 854 views | 11 replies |

sfj6167

Userid inserts into different user table fields

On my admin form (only for admins) I have a dropdown where I select user type.

(besides all the normal user stuff information)

If I I chose ""dealer" I need to capture userID (of the user I`m about to create) and insert that id into the users "dealerID" field

If I chose "salesperson" I need to capture userID (of the user I`m about to create) and insert that id into the users "salespersonID" field


So my question is:


How do I capture the id of the user I`m about to create ?

How do I on "Insert" tell the system, that if I selected dealer it should insert the id into the dealer field of users table
and if I select salespersion, it should insert the id into salesperson instead ?

best regards
Bison

Sign in to reply to this post

CraigRBeta Tester

The data assist insert record behavior will store the ID of the record that is created in a session variable.

Use this when adding records to the related tables

Sign in to reply to this post

sfj6167

Hi Craig

I get what you are saying, but the userID in session should go into the users table DEPENDED on what is chosen in the menu/list

If dealer(in menu/list) sessionid should be inserted in usertable field DEALER
If Salesperson (in menu/list) sessionid should be inserted in usertable field Salesperson...

How can I do this ??

again my question is:

How do I on "Insert" tell the system, that if I selected dealer it should insert the id into the dealer field of users table
and if I select salespersion, it should insert the id into salesperson instead ?

regards
Bison

Sign in to reply to this post

CraigRBeta Tester

Not sure I understand you correctly,

depending on what user type you select, do you insert a row into a specific table or do you have separate fields in your users table to store dealer and salesperson.?


if the former is the case, I would set up an insert behavior for each of the tables, and set up the trigger conditional to the value returned from the select list in the insert form, so that the specific trigger only fires when the appropriate value is chosen.

You did state however, state... "How do I on "Insert" tell the system, that if I selected dealer it should insert the id into the dealer field of users table
and if I select salespersion, it should insert the id into salesperson instead ?"


I am wondering, if this is the case, why do you have two separate fields ?

Sorry if I have misunderstood your objective.

If It helps, attach your database structure so I can take a look.

Sign in to reply to this post

sfj6167

Hi craig

I`ve attached the db table users.

What I need to do is this:

admins job is to be able to create dealers,superusers and admins.

If he creates superusers and admins, the groupid is suffecient, and works as it should.

if he creates a dealer
on insert the about to be created userID should be inserted into FH_id (Thats the part I dont know how to do)

That way we can always make querys against dealers...




---------------
On seperate Insert,update,results,search pages for dealers I need to do this:

Dealer can only create sales persons.
On insert of a new dealer the about to be created userID should be inserted into SA_id (Thats the part I dont know how to do)
On the same insert, since its a dealer, and he is logged in, I need to insert the usersession from the dealer into the about to be created salespersons FH_id. (Thats the part I dont know how to do)


I made a user exampel in the db, so you can see what I mean..

Dealer with id3 has created salesperson(id4), so when he does that, the row for salesperson should have dealers id into the FH_id and salespersons own id into the SA_id.

This way we can easily create quaries against dealers and there attached salespersons...

Also could you explain how to make a trigger that would on conditions trigger the different insert server behaviours...


Best
regards
Bison

Attached Files
users_example.txt
Sign in to reply to this post

CraigRBeta Tester

Hi Bison,
sorry to keep asking questions, but I just want to be clear as to your objectives.
From your table and data, I assume that a salesperson can be created by an admin (eg salesperson with UserID 2), or a dealer (eg salesperson with UserID 4).
You want to link salespersons with the dealer who inserted the record, (what about if salesperson was created by an admin ?)
I am trying to work out why you have 2 separate fields recording FH_id and SA_id.
Am I correct in saying that the only time a value is stored in SA_id, is when the user is a salesperson, and that the only time a value is stored in FH_id is when the user is a dealer or a salesperson, (where the userid of the dealer inserting the record is stored)
What is the purpose of the UserGroupID, does this identify admins/dealers/salespersons ?

If I am logged in, my userid should be stored as a session value.
So If I am a dealer, when I create a salesperson, my userid can also be stored in the record, so you can identify which salespersons I added/

changing the trigger conditions.

When you add an insert record behaviour, the trigger is typicaly something like..

<?php if (isset($_POST["Insert"]) || isset($_POST["Insert_x"]))  {
[[insert code block]]
} ?>



what you can do is change the parameters of the &#8216;if&#8217; statement so that the insert code is only triggered if (for example) the value of a posted text field equals a desired value. If the criteria is not met, the trigger will not fire.

Sign in to reply to this post

sfj6167

Hi Craig

You`re right about that it ONLY a dealer that should create salespersons (not admin) sorry my fault.

UserGroupID is for the admin areas for admin,superusers and dealers (maybe a future login and area, will be used for salespersons as well)

regards
bison

Sign in to reply to this post

CraigRBeta Tester

Could you not have a usergroupid (eg 4) for the salesperson ?

you could also store the id of the currently logged in user in the users table when creating a new record.

This way, you could identify salespeople easily and also to which dealer they are subordinate to, and not need both the FH_id and SA_id fields ?

would that work ?

Sign in to reply to this post

sfj6167

Hi Craig...

Yes "store the id of the currently logged in user in the users table when creating a new record"

Thats what I want to do, when a dealer creates a salesperson, but that id goes into the FH_ID.


The overall user system I`m building is for a product catalog with a later possibility for making sales competitions between dealerships og between all salepersons.

The UserGroupID is for acces to the different areas
FH_ID and SA_ID is usefull, for query different kinds of rapports and statistics.


We also have a design_type_ID which is for different themes, since the dealerships belong to different dealer chains . This way the theme (after login) will change to whatever colors and logo that dealer belongs to. (This gets set by the admin on dearler creation)


could you give me an example on how a trigger would look like to activate insert of a dealer !

DealerID = 2


Best regards
Bison

Sign in to reply to this post

sfj6167

Originally Said By: CraigR
  The data assist insert record behavior will store the ID of the record that is created in a session variable.

Use this when adding records to the related tables  



Craig - This does not happen...

The "save inserted ID in session" (on the insert server behaviour)is called WADA_Insert_ks_users

but binding that to the SA_ID dont return the id for the "id about to be created"

There is 2 WADA_Insert_users
and 1 WADA_Insert_ks_users

None of them contains the id created on insert!

What sessionname stores the ID created on insert ????

regards
bison

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...