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