AD Users and Groups in one Picker Control

  • 2 February 2015
  • 3 replies
  • 3 views

Badge +1

Hi,

 

I would like to fill Picker Control data source with combination of AD Users and AD Groups. SmartObjects I've created are based on AD Service2 service type. Is it possible to create custom SmartObject methost that will return combination of this two collections as a result?

 

Second thing is that I wolud like to save the template of Picker Control values in SharePoint list. Each user/group should be saved in separate row. So situation is that Picker Control data source should be filled by AD Users and AD Groups, but on the Initialization Picker Control values should be filled by multiple records from SharePoint list. Could You please help me find solution for that cases?


3 replies

Userlevel 1
Badge +8

Hi Wojtek

You could create a advanced smartobject that uses the AD Group GetGroups and AD User GetUsers methods in a single method call, but Im not sure I would recommend it as it might take a long time to execute (depending on how many users & groups you have in AD. I tried with our large AD and it took many minutes without finishing before I stopped it). I would suggest you have a separate picker control for Users and Groups and allow the user to select the one they require.

If I understand your second requirement correctly, you want the picker control to use a SharePoint list as a datasource? This should be easy enough by creating a SmartObject pointing to your list and using the List method in the picker data source. Be aware however that you can only set the data source of a picker at design time - it cant be changed at runtime. If what you want to do is use AD as the data source but save to SharePoint you can do this by calling the SharePoint list smartobject save method passing in the value in the picker.

Badge +1

Hi Andrew,

 

Thanks for fast replay. 

 

I'm making solution for small AD that's why long execute could not be a problem. How can I create sucha an advanced SmartObject? I've tried to execute GetGroups and GetUsers in a single SmartObject methot but I'm getting matrix of that two queries rather than sth like 'union all' - with is desired.

 

What about second question, I would like to bind AD SmartObject to Picker Control DataSource. Results of the Picker I want to save in SharePoint list. The problem is that Picker can have muliple values and every value should be save in separate SharePoint list record. I think I need here some kind of workaruond to reach this but I don't know which will be most optimal.

Userlevel 1
Badge +8

Hi Wojtek

 

Yes it appear the advanced smartobject using the GetUsers and GetGroups methods will cause a cross join, not a union, so that rules that out!

 

Perhaps look at using 2 picker controls - one tied to Users and the other Groups. You can get the user to select what they want to add (e.g. in a radio button) and hide/show the pickers accordingly.

 

If you want to use a picker that can have multiple values then I suggest you will need to use a workflow to add the values to SharePoint. The picker control values can be stored as XML or as a semi-colon delimited string. In the workflow you can use the XML or delimited string to parse out the values and add to Sharepoint. You will need to configure an activity to split the picker values out and loop through each one to perform the SharePoint save.

 

One way to implement using the delimited string option:

 

  1. Create a process level string datafield to hold the picker values.
  2. Drop a smartobject event onto the workflow and in the activity Destination Rule configure it to “Plan per slot (no destinations)”. You will need to click the Back button first and select Advanced to see this option.
  3. Select the “Use a list field to determine how many slots should be created” option. Then open the context browser and drop in the “Split” function found under Text. Add the datafield as the text and ‘;’ as the Separator.
  4. You can now use the “Instance Data” found under “Activity Destination Instance” node in the context browser to get each name, and use this field in the save to SharePoint smartobject event.
  5. Pass the picker control value(s) into the workflow as a datafield when you start the workflow on  your form (If you use two pickers you can concatenate their values)

Reply