Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Kentico Custom Field Items Based On Selected User View modes: 
User avatar
Member
Member
justin-liquidprint - 8/27/2013 11:03:03 AM
   
Kentico Custom Field Items Based On Selected User
I have added a new custom field in CMS_UserSettings table. The form control type is Multiple Choice. The data source for the control is set to a SQL Query. I would like to be able to populate the items in the control based on the selected user (Administration > Users). NOT the current user. Anyone know the syntax for this? Is it possible?

Here's my sample which pulls in the current users attribute. I need this to be the selected user.
SELECT ItemID, dealerNumber + ' - ' + dealerTitle 
FROM cPort_DealerLocation
WHERE culliganGroupID = {%CurrentUser.culliganGroupID%}
ORDER BY ItemID

Thanks!

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/27/2013 2:00:49 PM
   
RE:Kentico Custom Field Items Based On Selected User
If its a custom user setting you should be able to use this:
{% CurrentUser.UserSettings.GetValue("culliganGroupID", 0) %}
The 0 is the default object value if one isn't found.

User avatar
Member
Member
justin-liquidprint - 8/27/2013 3:19:31 PM
   
RE:Kentico Custom Field Items Based On Selected User
Thanks, FroggEye. I think my post was a little confusing. I can get back the culliganGroupID successfully from the CurrentUser object, that works good. Issue is I want to be able to populate the query with the selected user. i.e. Login to CMS Desk > Administration > Users > Select a user.

The custom field which gets displayed here should be pulled in based on the selected users culliganGroupID, not the CurrentUser.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/28/2013 7:29:21 AM
   
RE:Kentico Custom Field Items Based On Selected User
In that case you'd need to clone and modify the user selector form control. You can find it in CMSSiteManager>Development>Form controls>User selector. Make a clone of that control (I'd suggest following best practices when creating new controls, webparts, etc) and name it as you wish.

Then navigate the file structure in Visual Studio where you saved the control. You will have to modify the where condition which will start at or about line 453 of the SelectUser.ascx.cs file. You can choose to leave some f those items in place if you wish or simply remove all those items and set the where condition one time to get the user by your ID.

Once you have this control made, you should be able to add it to any alternative form, custom table, document type, etc. through the user interface AND use the control in your code behind.

User avatar
Member
Member
Accepted solutionAccepted solution
justin-liquidprint - 8/28/2013 11:49:39 AM
   
RE:Kentico Custom Field Items Based On Selected User
I was able to solve this using:
{%EditedObject.culliganGroupID%}