0

Through the UI its possible to pre-pend a number column - See screenshot below:

enter image description here

How can this pre-pended text be changed or added with PowerShell?

1
  • Hi, does below solution help you in any way? If yes, Please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Mar 9, 2023 at 11:35

1 Answer 1

0

For your requirements, you have to set below properties for the number column:

  • Unit='Custom'
  • CustomUnitName='ABC-SITE-Ref'
  • CustomUnitOnRight='FALSE'

Example:

Try using this PnP PowerShell code:

#Initialize Variables
$SiteURL = "https://contoso.sharepoint.com/sites/xyz"
$ListName= "Employees"
 
#Connect to site using PnP PowerShell
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
 
#Define XML schema for Number field
$FieldXML= "<Field Unit='Custom' CustomUnitName='ABC-SITE-Ref' CustomUnitOnRight='FALSE' CommaSeparator='TRUE' DisplayName='NumberCol' Format='Dropdown' IsModern='TRUE' Name='NumberCol' Percentage='FALSE' Title='NumberCol' Type='Number'></Field>"
 
#Add number field to list using XML
Add-PnPFieldFromXml -FieldXml $FieldXML -List $ListName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.