none
Setting default field values for multi-line text fields in lists?

    Question

  • For the multiple lines of text field in a list, I'm using SharePoint Designer 2013 to set a default value for the field, but I need that default value to include rich text formatting (the default value includes a formatted table). Is this possible without having to delve into JavaScript? And if so, how?
    Thursday, June 12, 2014 3:45 PM

Answers

  • Yes, we can :)

    You can do it with powershell

    $web = get-spweb <yourweb>
    $list = $web.lists["<yourList>"]
    $field = $list.fields["<yourField>"]
    
    $field.DefaultValue = "place your html code here"
    $field.update()

    hope that helps

    Thursday, June 12, 2014 4:07 PM

All replies

  • Yes, we can :)

    You can do it with powershell

    $web = get-spweb <yourweb>
    $list = $web.lists["<yourList>"]
    $field = $list.fields["<yourField>"]
    
    $field.DefaultValue = "place your html code here"
    $field.update()

    hope that helps

    Thursday, June 12, 2014 4:07 PM
  • Does that still allow data within the table created to be edited when I add a new item to the list?
    Thursday, June 12, 2014 4:49 PM
  • Yes.

    This only sets the default value for that field. The Field still editable

    Friday, June 13, 2014 8:07 AM
  • I can't get this to work with HTML code, only if I use plain text as the default value. Is there a special syntax I need to use for the HTML code?

    Can you give an example of HTML code you have made that works with the above? thanks!

    • Edited by HELKDGS Thursday, July 03, 2014 7:59 AM
    Thursday, July 03, 2014 7:58 AM
  • This is seriously awesome and way simpler than dealing with javascript in SPD.

    FYI in order to get HTML working, just input the HTML code. 

    $field.DefaultValue = "<b>this text is bold<b><br>now we're on a new line"

    Wednesday, May 20, 2015 2:21 PM
  • When attempting to run the code

    at the 3rd command  $field = $list.fields["Description"]

    I'm getting error: Cannot index into a null array.

    It's finding the get-spweb and the $web.lists, but then errors on the command listed above.

    I'm on SP2010, so perhaps that's the reason?  I just saw this is for SP2013.

    Thanks

    Monday, August 10, 2015 6:03 PM
  • When attempting to run the code

    at the 3rd command  $field = $list.fields["Description"]

    I'm getting error: Cannot index into a null array.

    It's finding the get-spweb and the $web.lists, but then errors on the command listed above.

    I'm on SP2010, so perhaps that's the reason?  I just saw this is for SP2013.

    Thanks

    It seems that your $fields array is empty or null. 

    Make sure you are loading the list correctly, use the display name of the list, and test the variable $list before try to access the fields.

    By the way, I tested it on SP2010 and it works.

    Tuesday, August 11, 2015 9:19 AM
  • How are you going to set up a default value for a multi-line text with powershell every time user adds a new item? When will you know to run your PS script? Will you have it in server task scheduler to update existing items, if so- what is going to be your schedule?

    I think jQuery works better in that instance as it populates a field on page load and it's client-side rather than putting the burden on your server. Just saying... 

    Wednesday, October 07, 2015 3:18 PM
  • How are you going to set up a default value for a multi-line text with powershell every time user adds a new item? When will you know to run your PS script? Will you have it in server task scheduler to update existing items, if so- what is going to be your schedule?

    I think jQuery works better in that instance as it populates a field on page load and it's client-side rather than putting the burden on your server. Just saying... 

    Hi Lukas,

    This is just to define the default value of the field.

    Once defined, every time you add a new item, the filed will be automatically filled with your content 

    Thursday, November 05, 2015 12:42 PM
  • Yes, but how do you define a default value for a column on a list item using PS? Where do you stick the code? Do you have to just run that code once on your sharepoint server for the value to preserve with each new item? If that's the case, then brilliant- I didn't know this can be done!

    Can you overwrite that default value later on using SharePoint library/list settings in GUI?

    Thursday, November 05, 2015 12:53 PM
  • Yes and Yes :)
    Wednesday, November 11, 2015 11:43 AM