locked
how to get the current username when I try to add an item in the list RRS feed

  • Question

  • I've a list with these columns

    Title

    Requestor

    On behalf of

    Select a service

    etc.

    What I want is, when the user add's an item (open's the form at first) in the list (..\Newform.aspx) the requestor field should be automatically shown the username. Now I defined the field as people and person, they need to do that manually, but  Iike to avoid this.

    I like to make the requestor READ ONLY and want to pre-populate the current username in that Requestor field....

    how can I achive this?

    ps: I posted my question to stackexchange site, but it's still pending for moderators approval. I think SharePoint site is not active on StackExchange.


    • Edited by EthemD Tuesday, October 20, 2015 11:22 AM correction
    Tuesday, October 20, 2015 11:18 AM

Answers

All replies

  • Check if you can use 'Created By' field which is a default field for any list item and stores the user details of the person who created the item.

    Else you can put some JS CSOM code on the New Form and get the current user's name/login and disable the field's control.


    Ram Prasad Meenavalli | MCITP | MCTS SharePoint | MCPD SharePoint | http://www.spdeveloper.co.in

    • Proposed as answer by romeo donca Tuesday, October 20, 2015 11:35 AM
    Tuesday, October 20, 2015 11:25 AM
  • @ RAM:

    Created By is filled in after submit, which is too late for me... I need it before creation..

    JS CSOM code? -> not familair with it. I assume I need Conent Editor WP and add there Javascript code.

    Ddo you have some sample code lines so I can google on what I need?


    • Edited by EthemD Tuesday, October 20, 2015 12:13 PM reply to user
    Tuesday, October 20, 2015 12:12 PM
  • Hi Ethem- you can use InfoPath to accomplish what you want. See Laura's post on how to do it:

    http://www.wonderlaura.com/Lists/Posts/Post.aspx?ID=178


    cameron rautmann

    • Marked as answer by EthemD Tuesday, October 20, 2015 2:02 PM
    Tuesday, October 20, 2015 12:20 PM
  • Hi Rautman, clicked on the link and looks fine. but this is InfoPath right?

    I'm in sharepoint designer and opend the Newform.aspx in Designer (Desing mode)... where do I see the Data, Data connections here? 

    Tuesday, October 20, 2015 1:13 PM
  • Tuesday, October 20, 2015 1:21 PM
  • Hi Rautman. These refers to C# inline code which is not allowed in SPD and the links with the site are death, but I like the idea using InfoPath. I'm familair with Infopath, but never used within SharePoint.

    I have 3 contenten types:

    -New request

    -approvalManager

    -approvalDirector

    Do I need to create 3 InfoPath forms?  How do I link with them with the list?


    now I have 3 *.aspx pages. which I use it in the URL
    • Edited by EthemD Tuesday, October 20, 2015 1:45 PM
    Tuesday, October 20, 2015 1:44 PM
  • You don't use that code in SP Designer, you add it to the site in a content editor (read it more carefully).

    As far as InfoPath, I suggest using the "customize form" button in the ribbon so it opens the list in InfoPath. Then I'd create 3 different views for each of your content types. Set a rule on form load to select the correct view.


    cameron rautmann

    Tuesday, October 20, 2015 1:53 PM
  • ok. got it thanks for the help.
    Tuesday, October 20, 2015 2:01 PM