AutoPopulate fields with userdetails based on UniqueID field

Welcome Forums General PowerShell Q&A AutoPopulate fields with userdetails based on UniqueID field

Viewing 0 reply threads
  • Author
    • #5596
      Topics: 1562
      Replies: 0
      Points: 1
      Rank: Member

      by chakram at 2013-02-26 05:58:09


      I have a requirement in the SharePoint 2010 List containing the fields – Unique ID (People picker), FirstName(SingleLineofText), LastName(SingleLineofText) and so on.

      Whenever the user fill in the "UniqueID" column, the fields (Firstname and Lastname) should be automatically populated based on the UniqueID.

      I need the powershell script for the same


      by poshoholic at 2013-02-26 06:54:20

      Something like this?
      function New-User {<br />    [CmdletBinding&#40;&#41;]<br />    param&#40;<br />        [Parameter&#40;Position=0, Mandatory=$true&#41;]<br />        [ValidateNotNullOrEmpty&#40;&#41;]<br />        [System.String]<br />        $Name<br />    &#41;<br />    # First clean up the input &#40;remove leading/trailing whitespace, plus replace any paired spaces with a single space&#41;<br />    $Name = $Name -replace &#39;^\s+|\s+$&#39; -replace &#39;\s+&#39;,&#39; &#39;<br />    # Now get the name parts<br />    $NameParts = $Name -split &#39;\s&#39;,2<br />    # Finally return an object with the name, firstname, and lastname properties<br />    New-Object -TypeName PSObject -Property @{<br />        Name = $Name<br />        FirstName = $NameParts[0]<br />        LastName = $NameParts[1]<br />    }<br />}
      Here’s some output from that command:
      PS C&#58;\&gt; New-User 'Kirk Munro'</p><p>Name                                    LastName                                FirstName<br />----                                    --------                                ---------<br />Kirk Munro                              Munro                                   Kirk</p><p>PS C&#58;\&gt; New-User 'Miguel de Icaza'</p><p>Name                                    LastName                                FirstName<br />----                                    --------                                ---------<br />Miguel de Icaza                         de Icaza                                Miguel</p><p>PS C&#58;\&gt; New-User 'Joe'</p><p>Name                                    LastName                                FirstName<br />----                                    --------                                ---------<br />Joe                                                                             Joe</p><p>PS C&#58;\&gt; New-User '     Too     ManySpaces    '</p><p>Name                                    LastName                                FirstName<br />----                                    --------                                ---------<br />Too ManySpaces                          ManySpaces                              Too

      by chakram at 2013-02-26 23:02:41

      Hi Kirk,

      Yes, it is almost same, but i need to get the userid/uniqueid(PeoplePicker) from the list field and it should autopopulate the other fields first and last name based on this unique id, i have attached the screenshot of the requirement, kindly let me know if that is possible through powershell for teh SharePoint 2010 List.


      by poshoholic at 2013-02-27 07:16:55

      Ah, I thought you were using SharePoint as an example, looking for a script to do that work. I get what you’re looking for now. I’m not a SharePoint guy, so to help you get the right assistance for this I’m going to copy the thread into the PowerShell and SharePoint forum. Someone over there should be able to help you.

Viewing 0 reply threads
  • The topic ‘AutoPopulate fields with userdetails based on UniqueID field’ is closed to new replies.