tags:

views:

202

answers:

1

I'm new to using SugarCRM. I want to have a users page that does the following:

1) allow a user to create sub-users, and each sub-user can then create additional sub users

2) display users in an expandable and collapse-able hierarchical tree structure.

3) add more attributes to each user

4) any newly created user should be able to login to sugarcrm using sugar's existing authentication.

Does anyone know how to do this? Or if they can recommend tutorials/resources for me to study?

A: 

John, you will need a one to many relationship based on a custom module. One user can create a sub user.

So begin by defininig that module and relationship inside of SugarCRM studio. Once this is defined if you try to throw a subpanel on the Users module you will notice an add / delete / edit button, allowing you to add / delete sub users.

To add more attributes to your user you simply go into studio, select that module and add _c (custom fields) to the corresponding table. You can add custom text, int, long, float, varchar, etc fields.

JonH
@JonH - that's really cool. The custom module is creating whole new tables in the database. Is it possible for me to define the one to many relationship against sugar's existing user table? The reason is that after I create new users in my module, I want them to be able to login via sugar's existing authentication and user management system.
John
@John - You are looking at a self joining table, that is a circular relationship, in theory this is possible and in sugar unfortunately it is a bug. I think the SugarCRM team is working on circular relationships as we have needed to do the same thing in the past.
JonH
@JonH - Is it possible to have Sugar define a junction table with columns parent_id, child_id, (both are FK to the user_id of the user table) as a way to define user heirarchy? Or can you think of any other way to achieve the same result? thanks!
John
@John - The question is how are you going to do a circular reference in Sugar? What version are you running, they might have fixed circular references in 5.2.5? Are you running professional or community edition? Can you define a one to many relationship to a table to itself? Say users -> users_1
JonH
@JonH-I'm using community Version 5.5.0 Build 6653. Unless, I'm misinterpreting the results, it looks like circ. ref. is do-able. I have a junction tbl userm_user_userm_user_c that has a parent_id and child_id both referencing userm_user.id. So this is what i want to do, except I'd like to apply it to the sugar's native user table instead....Do you think it's possible? Hope I'm not getting confused, and thanks so much for helping!
John
@John - I guess I do not understand what you are after, maybe posting in a sugarcrm forum will help as that way that is a more discussion type environment. Stack overflow's use of comments doesn't help get all the details. Are you inserting data in a user defined table and then you want to use that data to insert into the main sugar crm users table? If so this becomes a simple script of inserting data from one table to another, very possible we use SQL Server.
JonH
I dn't want to define any tables, only altar existing users table. I just noticed a users.report_to_id. I think this is all I really needed! Thanks JonH! I'll try the forums too!
John
@John - No problem please make sure you mark this as an a ccepted answer so that anyone else who uses SugarCRM (cricket) and runs into this issue sees an answer. That table stores the managerid of the associated user. It may well be what you need.
JonH