Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Connecting a user to a document type View modes: 
User avatar
Member
Member
ovidiu.lazar-evozon - 10/5/2011 10:03:54 AM
   
Connecting a user to a document type
Hi,

I have a special type of users who can log into the system. I added 2 custom fields to the User type in SYstem tables: IsDealer and IsFeaturedDealer.

Users who are dealers have the ability to create Dealerships. I have added a document type Dealership.

Featured dealers have the ability to add logos for each dealership they own. This matters in the search results, when outside users search for dealerships.

Two questions:

1. How do I connect users who have the IsDealer flag set with the Dealerships? I can add a DealerID custom field to the Dealership document type but I don't know how to fill it. The scenario is that a dealer logs into Kentico and then adds/removes dealerships. The administrator will set the two flags, IsDealer and IsFeaturedDealer.

2. I need to display dealerships. I don't need to display users yet. How can I determine if the dealer to which a dealerships belongs to has the IsFeaturedDealer flag set? I am using a custom transformation of type ASCX.

Thanks guys!

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 10/5/2011 4:14:26 PM
   
RE:Connecting a user to a document type
Hello,

1) You can create a custom form control according to our documentation which will populate the DealerID custom field on each custom document automatically with some custom code. You can use the UserID to identify the user/dealer.

2) That can be done with a custom sql query in a repeater. The query below displays all the Dealerships (the dealership table - this needs to be changed according to your setup) which belong to any user which is a featured dealer.

SELECT * FROM Dealerships WHERE UserID IN (SELECT * FROM CMS_USER WHERE IsFeaturedDealer = 'true')

To tweak this query please use MS SQL Server Management Studio.

Best regards,
Boris Pocatko

User avatar
Member
Member
ovidiu.lazar-evozon - 10/7/2011 10:52:11 AM
   
RE:Connecting a user to a document type
Thanks,

You're right, the dealer user is actually a kentico user. as far as 2), only the current user can create a dealership so i think i can pull it off without the use of custom sql.