none
Workarounds for using Word 2010 content controls for Sharepoint Managed Metadata fields? RRS feed

  • Question

  • I realize that Managed Metadata (MM) fields don't show up in the Word Insert, Quick Parts list (and I think I understand why).  So I created a new text field in Sharepoint and use a Sharepoint workflow to populste the Text field with the value of the Sharepoint MM field.  Those fields are available as Quick Parts and I can insert them into my document.

    BUT changes to the text fields are not reflected in the Managed Metadata fields, even if the new value in the text field is an actual entry in the MM list.  (Everything works correctly if the MM entry is edited in the Document Iniformation Panel (DIP)).  The users need to be able to edit these Sharepoint fields both in the Word document itself and in the Document Information Panel (DIP) so I'm at a dead end. 

    I have thought of two options:  1.  Create a Word macro that connects the text field back to the MM field in the DIP so that if an actual entry is typed into the text field, the MM field changes accordingly  (I think this macro would need to compare the text to the entries in the MM list, find out the corresponding number within the MM list and associate that number to the MM field itself.) or 2.  Find a way to actually enter the MM field (or something linked directly to it) into the Word document itself.

    If you think that either of these options are possible, I'd appreciate hearing how to actually make it happen.  Or if there are other options, please let me know.  Thanks in advance. Carol.

    Sunday, May 5, 2013 5:55 PM

Answers

  • <<
    Assuming this would be done by a VSTO Word add-in, can you point me to some good resources that would give me a start in creating one of those?

    >>

    I hope Cindy drops by as she knows much more about that than I do.

    > And, just for future reference, how can I get to the XPath for a Content Control in a Word document? 

    to retrieve it,

    e.g. ActiveDocument.ContentControls(1).XMLMapping.XPath
    to set it, e.g.
    ActiveDocument.ContentControls(1).XMLMapping.SetMapping "the xpath"

    (There is a second parameter for specifying prefix mappings. You may need to use it).

    BTW I had a look at the InfoPath Custom DIP thing and although it is quite easy to set the value of the TermName from (say) a DIP control that contains the name the user entered, that does not cause the DIP control to look up the value entered either. My guess is that the value has to be entered via the dialog box, but that is onlya guess.


    Peter Jamieson

    Monday, May 6, 2013 7:04 PM

All replies

  • This is probably not going to tell you much that you do not already know, but I had a quick look at this, just looking at a single-valued MM field. First, my MM field does show up in the Quick Parts list (this is Word 2010 and SP 2010), but it is configured as read-only - i.e. it is there purely to reflect the value chosen in SP or the DIP. When I look at the control's XPath, it points to the first Terms element in the XML. But the Terms element is like this

    <Terms>
      <TermInfo>
        <TermName>the value</TermName>
        <TermId>a guid</TermId>
      </TermInfo>
    </Terms>

    The DIP and the content control both display the TermName. If I change the Xpath of the content control so that it points to the TermName and make the control writable, you can insert a new value in the content control, and as far as I can tell, it will be written back to SharePoint. But unfortunately, both SharePoint and the DIP are driven by the value of the TermID, so the TermName does not actually appear in either SharePoint or the DIP.

    However, if you change the TermID in the XML, the DIP's display value does update. But it does not then replace the TermName in the XML.

    So I suspect that to get anything to work in Word, you would either have to know, and hardcode, all the TermNames and TermIDs for the particular MM term set you want to use, or be able to discover them at runtime. If either of those things is possible, getting either the TermName or the TermId in a content control should be enough to allow code to do the rest.

    I haven't yet looked at ways to retrieve TermName/TermId values in Word (or whether it is even possible), but I also wonder whether this is something you could do by customising the DIP in InfoPath.


    Peter Jamieson

    Monday, May 6, 2013 5:33 PM
  • Thanks, Peter, for that research.  You are right that a single value Managed Metadata column does show in the DIP and in the Quick Parts list (boy, do I wish we only needed single value MM fields!).  I think that you are correct in saying that I'm going to need to discover the TermNames and TermID's for MM term set(s) that need to be edited in Word. 

    Assuming this would be done by a VSTO Word add-in, can you point me to some good resources that would give me a start in creating one of those?

    And, just for future reference, how can I get to the XPath for a Content Control in a Word document?  I feel like I should know how to do this but I just can't figure it out.

    Thanks again.  Carol.

    Monday, May 6, 2013 6:21 PM
  • <<
    Assuming this would be done by a VSTO Word add-in, can you point me to some good resources that would give me a start in creating one of those?

    >>

    I hope Cindy drops by as she knows much more about that than I do.

    > And, just for future reference, how can I get to the XPath for a Content Control in a Word document? 

    to retrieve it,

    e.g. ActiveDocument.ContentControls(1).XMLMapping.XPath
    to set it, e.g.
    ActiveDocument.ContentControls(1).XMLMapping.SetMapping "the xpath"

    (There is a second parameter for specifying prefix mappings. You may need to use it).

    BTW I had a look at the InfoPath Custom DIP thing and although it is quite easy to set the value of the TermName from (say) a DIP control that contains the name the user entered, that does not cause the DIP control to look up the value entered either. My guess is that the value has to be entered via the dialog box, but that is onlya guess.


    Peter Jamieson

    Monday, May 6, 2013 7:04 PM