none
Populate drop-down in a custom list

    Question

  • Hello all

    Is it possible to populate dynamically field such as a drop-down or person picker in a custom list?

    I need the drop-down to populate with the user's manager, so that when I start the workflow I set the first level of approval that user's manager. 

    I would need it to be populated on page load, so that when the user is making the approval it can already select its manager in the selection field

    If the manager field is not populated I need to make the user enter it.

    Thank you

    Wednesday, April 26, 2017 11:38 AM

All replies

  • Hi Ion,

    For your request, I suggesting you adding a rule in Form Load in InfoPath to customize your drop down column. Follow the steps below:

    In the list, click Customize Form, then the InfoPath opened.

    In InfoPath, click Form Load in Data Tab:

    Then add a rule and add a action to set a field view:

    Finally, publish the form. When you create a new item, the drop down column will populate the user you configure.

    Best regards,

    Grace Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 27, 2017 12:52 PM
  • Thanks Grace

    I'll give it a try and let you know

    Friday, April 28, 2017 8:19 AM
  • Hi Ion,

    Is there any update?

    Best regards,

    Grace Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, May 01, 2017 10:01 AM
  • Hi Ion,

    If you are using SharePoint Designer with 2010 Workflow you will lookup the Manager information from the workflow code as follow.

    Click on Action button on the toolbar and select Lookup Manager of the user.

    

    However if you are using the 2013 workflow you have to call it through web services. It is a little bit complex than 2010 version.

    _____

    The another option is from the InfoPath Form. I use to call user information through GetUserProfileByName Web service.

    The steps are:

    1. Create the new data connections, Select the Receive data option then Next.

    2. Select SOAP Web Service then Next.

    3. Enter location of SOAP Web Service definition,  the format is: http://yoursiteurl/_vti_bin/Userprofileservice.asmx?WSDL

    4. Next, find the GetUserProfileByName in the list of operation box then Next.

    5. You will see the parameters in the list by default and then Next.

    6. It will ask you to store in the form template, I am not usually check that one, so keep it uncheck if you don't want to store in your form.

    7. Set your data connection name, I use to leave as default and uncheck the Automatically retrieve data because I will call it myself on the Form load event. Then click Finish.

    Now you have to query the user information through Form load event.

    There is one thing we have to adjust before query the connection. Since 2013 version of SharePoint, whenever we call the current userName information, it will give us this format "i:0#.w|domain\user". Therefore, I use to remove those format especially i:0#.w| from the name by adding the rule in Form load before query the connection. The steps are:

    1. Click on the Data Tab and Select Form Load.

    2. In the rules panel, define the rule for removing this i:0#.w| from the userName (which is current user information whoever create or fill up this form).

    Please note the AccountName I assigned the value is in the connection as below picture which you have to select in the Field Name before you put the formula of substring in the value box.

    After that create the second rule in the Form Load to query your require data from the user profile. 

    - First assign the value to your created field (column) of InfoPath form as below in Run these actions section.

     

    Then select the Query for data and select your connection which is GetUserProfileByName.

    Now you can run and see the result in the InfoPath Form and the lookup user information and manager name will be there. You can use that value in the workflow to run the approval or task assignment to the user line manager.

    Hope the steps are easy to follow and get your requirement. Please let me know if you have any questions or doubts.

    Cheers!

    Monday, May 01, 2017 11:33 AM
  • Hello Grace

    I have, just this morning, I was free yesterday.

    Indeed it works, but I have to find  a way to populate like ... not with a predefined value, what I would need if for example to load the logged on user of that page.

    But thanks anyway, I learned something new today

    Tuesday, May 02, 2017 8:11 AM

  • Hello Pyae

    1. You said that site url is like http://yoursiteurl/_vti_bin/Userprofileservice.asmx?WSDL. However this does not seem to work for me. If I put https as is https://contoso.sharepoint.com/sites/useronboarding/_vti_bin/Userprofileservice.asmx?WSDL is appears to work. "useronboarding" is the name of my site, in Sharepoint in O365.
    Am I doing something wrong when I create a new connection only with http and not https?
    With "http" I get  " The data source file is accessed through a redirection from a different domain, which is not allowed. If you want to use this data source file, copy it to a location within your security domain.Access is denied."

    2. The field in which I want to store the "manager" is caled like this : Name :  AplicantsManagerLbl displayName AplicantsManager.
    So, that I create the rule . In the field value I put Value[Name = "Manager"], Where "Manager" is typed letter by letter by me

    So in the end it looks like this

    But when I load the form is empty, my field I mean

    PS: I a using 2013 workflow





    Tuesday, May 02, 2017 12:37 PM
  • Hi Ion,

    For the data connection error, I was assumed that you are going to connect to the user profile within the site collection/farm.

    As I figure it out, you have to fetch the user information (let's assume with current logon user) first in order to lookup his manager name.

    1. Please refer to Get Username rule in the steps which I try to get the current username and put the value into the GetUserProfilebyName's AccountName field under Query section. So whenever you call that data connection it will be query to the current user information.

    2. The next step is to assign the query information to your appropriate field in the InfoPath form. The way you fetch the Manager is correct way. You have to manually type the field to match the profile column name. Eg: "Manager", "PreferredName", "Title","WorkEmail","WorkPhone","Department", etc.

    Please let me know if it is not working for you. Cheer!

    Monday, May 08, 2017 7:57 AM