locked
Help with script to create UserID - in Infopath form RRS feed

  • Question

  • Hi,

    I am in the process of creating a form for creating new users (both internal and external users) - I have linked the following fields from AD into the form:

    - givenName, initials, sn, telephoneNumber, mobile, company, street, l, postalCode,st, co, mail, accountExpires, cn, name, and displayName.

    I have run into a roadblock where I would like the form to automatically create a sAMAccountName and userPrincipalName based on our naming convention for userIDs.

    Our naming convention for our accounts is: first five characters of surname + first initial + middle initial (if no middle initial, then '0') - ie - John Smith - smithj0, George M. Johnson - johnsgm

    I figure that I will need to use a formula that uses the concat and substring? Just not sure where to start.

    The script would also need to include checking Active Directory to see if the user ID currently exists.

    The other issue I have is if the user has less than 5 letters in thier surname - ie - James Ali. We substitute any missing letters with '0s', so James Ali would be ali00j0. If there were another user called Jonathan Ali - we would also need a rule to increment the user ID to ali00j1 after the AD check is complete.

    Hope that makes sense.

    Any help is much appreciated!

    Thanks :-)

    Sunday, March 16, 2014 11:38 PM

Answers

  • InfoPath is part of Office 2013 and is delivered with Office 365 accounts.  It is not a scripting tool.  It is simple XML based forms design tool that can build SharePoint forms.

    The documentation and support is on the Office site.


    ¯\_(ツ)_/¯

    • Marked as answer by Bill_Stewart Monday, March 24, 2014 5:04 PM
    Monday, March 17, 2014 3:46 PM

All replies

  • Hi,

    I am in the process of creating a form for creating new users (both internal and external users) - I have linked the following fields from AD into the form:

    - givenName, initials, sn, telephoneNumber, mobile, company, street, l, postalCode,st, co, mail, accountExpires, cn, name, and displayName.

    I have run into a roadblock where I would like the form to automatically create a sAMAccountName and userPrincipalName based on our naming convention for userIDs.

    Our naming convention for our accounts is: first five characters of surname + first initial + middle initial (if no middle initial, then '0') - ie - John Smith - smithj0, George M. Johnson - johnsgm

    I figure that I will need to use a formula that uses the concat and substring? Just not sure where to start.

    The script would also need to include checking Active Directory to see if the user ID currently exists.

    The other issue I have is if the user has less than 5 letters in thier surname - ie - James Ali. We substitute any missing letters with '0s', so James Ali would be ali00j0. If there were another user called Jonathan Ali - we would also need a rule to increment the user ID to ali00j1 after the AD check is complete.

    Hope that makes sense.

    Any help is much appreciated!

    Thanks :-)

    • Merged by Bill_Stewart Sunday, March 16, 2014 11:56 PM Duplicate
    Sunday, March 16, 2014 11:38 PM
  • So you want someone to write a username generation algorithm for you, based on your business rules?

    Here are some PowerShell suggestions:

    1. Get-ADUser can tell you if a user already exists.

    2. $string.Length (length property of a String object) can tell you the length of a string.

    3. Double-quoted strings in PowerShell can include embedded variables and string formatting.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 17, 2014 12:01 AM
  • You need to post InfoPath questions in the InfoPath Office 2013 forum.  THey will point you to resources that will help you learn how to build forms in InfoPath.

    InfoPath is part of offce.  It uses formulas like Excel and has a formula editor.


    ¯\_(ツ)_/¯

    Monday, March 17, 2014 12:05 AM
  • I'm not familiar with that tool, but it looks as though it's already obsolete:

    http://blogs.office.com/2014/01/31/update-on-infopath-and-sharepoint-forms/

    Agree with jrv: This forum is really about scripting and not Microsoft Office tools.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 17, 2014 3:04 PM
  • InfoPath is part of Office 2013 and is delivered with Office 365 accounts.  It is not a scripting tool.  It is simple XML based forms design tool that can build SharePoint forms.

    The documentation and support is on the Office site.


    ¯\_(ツ)_/¯

    • Marked as answer by Bill_Stewart Monday, March 24, 2014 5:04 PM
    Monday, March 17, 2014 3:46 PM
  • Agreed, the OP is not asking his question in the correct forum.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 17, 2014 4:14 PM