How to show user names from active directory for the comma separated IDs stored in the database

  • 9 December 2014
  • 4 replies
  • 2 views

Badge +2

Hi guys,

We are stuck in a development nightmare where we have thought of all possible options but still did not find a solution.

Any help is deeply appreciated. Thanks in advance.

 

Business requirement: Each location can have one or more supervisors. While creating the locations we are using a picker

control to select users from the active directory and we are saving comma separated user login IDs in the database along

with each location.

Data saved:

Location A          hcljohn.S,hclPeter.a
Location B          hclStephen.p,hclmark.d
Location C          hclGeorge.d

Desired output in a list view:

Location A         John Smith, Peter A
Location B         Stephen Parker, Mark David
Location C         George D


Problem: While displaying a list of locations in a list view we need to display the user names (comma separated) against

each location instead of user IDs.
 
Option 1: User names have to be fetched from Active Directory as per the comma separated user IDs. We have tried to do this but did not find any solution.

Option 2: Save user names also along with user IDs (comma separated). But we didn't find a way to save the display property (comma separated) from a picker control.

Option 3: We tried to split the data so that we get repeating locations with single user ID
Example
Location A      hcljohn.S
Location A      hclpeter.a.

This way we can get the user names from AD but we didn't find a way to group the data back to get unique location with comma separated user names.

 


4 replies

Badge +10

Would this solution work:

 

You have one list view. You have two columns Location (drop down list) and Employee(picker control only one user can be picked).

You click an add button, it add a row. You slect a Location and then you select a employee from the picker.

 

Now save all data when the form is submitted or any other event that you want.

When you list the data you just call the list method on that list view. Even if you are storing the userId the picker should be able to resolve it to an employee display name or whatever you have set the picker control to show.

 

Hope this helps.

 

Badge +2

Thanks for the quick reply.

If it is only one user per location, we can make it work but with comma separated users per location we are not able to make it work. And it seems that the picker control is meant to be for data entry and not for data display.

Userlevel 1
Badge +8

Hi Punit

 

This is one approach you could take.

 

Add the following controls:

  1. Picker control configured to select ony one name (Allow Mulitple = false) using AD User as data source

  2. 2 data labels (or text box/text area) called "Name Data Label" and "Display Name Data Label"

  3. An "Add User" button

 

Configure a rule on your add user button to check that a value exists in the picker. If there is a value then add a rule to transfer data to the data labels as follows (see attached image).

 

For the "Name data label", transfer the "Name" property from the AD User smartobject under the Picker control, followed by a comma, and then the "Name Data Label" itself.

 

Repeat for the "Display Name data label" this time transferring the "Display Name", a comma and the "Display Name Data Label".

 

Then clear the value from the picker control to allow the user to add another name.

 

You now have 2 controls containing comma delimed account names and display names. You will have an extra comma at the end of the names - you might be able to remove this with an expression. You can then save these values to your SmartObject.


11245i493F82671820032B.png
12841i8C2D6BC2379FA8D7.png
Badge +1

Hi Punit,

 

just a recommendation from my experience. Avoid executing a list method on an AD SmartObject. We have about 900 Users in the AD and it takes between 8-12 seconds to fetch all users to display them in a dropdown list.

 

That being said I would suggest a slightly different approach using Option 3.

Store the logins in a separate table.

Create an additional Table in the database and store the user logins and displayname.

Create a Stored Procedure which returns the desired data in the desired format.

Add the stored procedure as a new SmartObject method.

Use the new SmartObject method when you only want to display the data.

 

Regards,

Daniel

Reply