locked
Sharepoint & Word 2010 - how to hide quick parts when left empty - displaying "required field" RRS feed

  • Question

  • Hi,

    I have a SP list that when a new item is created, through workflow it creates a word 2010 document in a document library and inserts these columns using quick parts.  There is always going to be instances where fields are left empty.

    If I then edit the document, I am not able to save the document because the document panel says a field has been left blank.

    So I then found a great article on using an IF field to hide an empty/blank field - http://www.teylyn.com/articles/sharepoint-articles/hide-empty-sharepoint-metadata-columns-in-word-2010/.  This does work well, but for some reason in my document, if I need to delete the text out of the field, then it won't go blank again - it keeps the previous text in there.

    Is there either a way to not make the field required - or is there a way to ensure that the field goes blank if any text is removed from that field.  In the demo provided by Teylyn, her's does work, but for some reason mine does not...

    Apologies if I have not posted this in the correct forum.

    Monday, February 11, 2013 4:00 AM

Answers

  • I tried the method shown in the link you gave, and have the same experience as you, i.e. changing the value to contain something changes the values of all the content controls, but changing the value to "empty" only shows the placeholder text for those content controls that are not nested inside fields (it's not just IF fields). It doesn't matter whether I use a "built-in" content control, cf. properties, as in your link, or one from a SharePoint list.

    I have to say that I can no longer remember whether the behaviour was always like that, but it's difficult to see how Teylyn's example could ever have worked unless either the behaviour used to be like that, or some other factor is involved. The behaviour appears to be the same in Word 2007, 2010 and 2013 at the moment. I think you have probably posted a question in Teylyn's thread so it will be interesting to see if you get an answer there.

    As for "required", you set that in the settings for the column in the SharePoint library. However, with text fields, the field can be empty but apparently cannot contain spaces. But I'm not sure which problem allowing the field to be empty would solve for you.


    Peter Jamieson

    • Marked as answer by Tony Chen CHN Monday, February 25, 2013 8:11 AM
    Tuesday, February 12, 2013 6:46 PM

All replies

  • I tried the method shown in the link you gave, and have the same experience as you, i.e. changing the value to contain something changes the values of all the content controls, but changing the value to "empty" only shows the placeholder text for those content controls that are not nested inside fields (it's not just IF fields). It doesn't matter whether I use a "built-in" content control, cf. properties, as in your link, or one from a SharePoint list.

    I have to say that I can no longer remember whether the behaviour was always like that, but it's difficult to see how Teylyn's example could ever have worked unless either the behaviour used to be like that, or some other factor is involved. The behaviour appears to be the same in Word 2007, 2010 and 2013 at the moment. I think you have probably posted a question in Teylyn's thread so it will be interesting to see if you get an answer there.

    As for "required", you set that in the settings for the column in the SharePoint library. However, with text fields, the field can be empty but apparently cannot contain spaces. But I'm not sure which problem allowing the field to be empty would solve for you.


    Peter Jamieson

    • Marked as answer by Tony Chen CHN Monday, February 25, 2013 8:11 AM
    Tuesday, February 12, 2013 6:46 PM
  • Hi Peter,

    Thanks for your comments.  I think even though Teylyn's blog refers to Sharepoint fields, she is using the built-in fields in Word so maybe that's why she doesn't have the issue when making it blank.  I have posted on her site but have not had any reply as yet.

    In relation to the required field, it is definately not set as required in the Sharepoint List.  It doesn't matter what field I make blank - they all come back as "required".

    Tuesday, February 12, 2013 10:28 PM
  • Yes, the interesting thing about the video on Teylyn's site is that it actually uses the content control version of the categories built-in property, not a SharePoint field. But I also tried that here, and it behaved the same way as the SharePoint variables. So something is different. I've tried starting Word with the /a switch to avoid loading global addins, but that made no difference.

    re. the "required," I don't know what is happening there. I assume no-one has created any validation formulas in Sharepoint? If there's no validation what I find is that if I type a space into the field in the DIP and tab to the next field, the red dotted border appears. If I click back in the marked field, nothing I do "clears" the field and removes the red line. I have to type something non-blank in the field, tab out again, then go back into the field and delete the thing I typed. But I don't see the same message as you either.


    Peter Jamieson

    Wednesday, February 13, 2013 9:43 AM