locked
Auto-populate the viewer in a column RRS feed

  • Question

  • Can anyone think of a way to auto-populate the values of a column, in a list upon page load, with the the account name of the active user viewing the list, utilizing the "GetUserProfileByName" data connection? I tried it in InfoPath designer on an already created list with a formula as the default value, but the value is still blank....

    Friday, June 28, 2013 9:02 PM

Answers

  • Ok then set the data connection to not retrieve information automatically, add into your on form load rule, a condition

    if myField is blank then perform action above, you will need to add an additional action of query data source and query the GetUserByName data source before doing the set a fields value rule.

    now when your form opens, if the AccountName is not set, then it will query the data source and set the fields value, if it is already set it will do nothing.  You can then also make your AccountName field Read Only so users dont alter its value.


    Regards

    Sergio Giusti
    http://sergioblogs.blog.co.uk/

    Whenever you see a reply and if you think is helpful, click " Alternate Text Vote As Helpful". And whenever you see a reply being an answer to the question of the thread, click " Alternate Text Mark As Answer".

    • Marked as answer by Qiao Wei Monday, July 8, 2013 1:37 AM
    Thursday, July 4, 2013 8:34 AM
  • In your form add a data connection to your UserProfileService and select the GetUserByProfile option and choose to have it autoretrieve the information.

    Now in your form, select the DATA Tab and choose On-Form Load Rules, add an Action Rule.  Have the Action Rule 'Set a fields value' and set the field you wish to set with a connection to the Account Name/Display Name of the user. 

    For the Text, if you want to display the Account Name for the user, then enter: AccountName (case sensitive)

    if you want to show their Display Name, then enter: PreferredName (case sensitive)


    Regards

    Sergio Giusti
    http://sergioblogs.blog.co.uk/

    Whenever you see a reply and if you think is helpful, click " Alternate Text Vote As Helpful". And whenever you see a reply being an answer to the question of the thread, click " Alternate Text Mark As Answer".

    • Marked as answer by Qiao Wei Monday, July 8, 2013 1:37 AM
    Wednesday, July 3, 2013 3:34 PM

All replies

  • I'm not sure what you're showing in the picture -- is this the column heading or you want the user name to appear in the items in this view (I'm assuming it's a view).

    For reference, fields in a list aren't updated unless the item has been edited. 


    Friday, June 28, 2013 10:02 PM
  • In your form add a data connection to your UserProfileService and select the GetUserByProfile option and choose to have it autoretrieve the information.

    Now in your form, select the DATA Tab and choose On-Form Load Rules, add an Action Rule.  Have the Action Rule 'Set a fields value' and set the field you wish to set with a connection to the Account Name/Display Name of the user. 

    For the Text, if you want to display the Account Name for the user, then enter: AccountName (case sensitive)

    if you want to show their Display Name, then enter: PreferredName (case sensitive)


    Regards

    Sergio Giusti
    http://sergioblogs.blog.co.uk/

    Whenever you see a reply and if you think is helpful, click " Alternate Text Vote As Helpful". And whenever you see a reply being an answer to the question of the thread, click " Alternate Text Mark As Answer".

    • Marked as answer by Qiao Wei Monday, July 8, 2013 1:37 AM
    Wednesday, July 3, 2013 3:34 PM
  • Extending question from this:

    What if I do not want to change the value of the AccountName field once the form has been saved for the first time? I mean that every time a person opens this form, the UserProfileService will get the name of the person who is working on the form. If I push it to sharepoint column and someone else edits the form later, this will change. How can I prevent that from happening? Is the best way to do this is to save it in another field?


    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

    Wednesday, July 3, 2013 4:15 PM
  • Ok then set the data connection to not retrieve information automatically, add into your on form load rule, a condition

    if myField is blank then perform action above, you will need to add an additional action of query data source and query the GetUserByName data source before doing the set a fields value rule.

    now when your form opens, if the AccountName is not set, then it will query the data source and set the fields value, if it is already set it will do nothing.  You can then also make your AccountName field Read Only so users dont alter its value.


    Regards

    Sergio Giusti
    http://sergioblogs.blog.co.uk/

    Whenever you see a reply and if you think is helpful, click " Alternate Text Vote As Helpful". And whenever you see a reply being an answer to the question of the thread, click " Alternate Text Mark As Answer".

    • Marked as answer by Qiao Wei Monday, July 8, 2013 1:37 AM
    Thursday, July 4, 2013 8:34 AM