Home > InfoPath, InfoPath Deployment > Promoting Properties – Expose InfoPath Fields as Site Columns

Promoting Properties – Expose InfoPath Fields as Site Columns

September 29, 2008 Leave a comment Go to comments

Well First Let me explain what does it mean by Promotion and Demotion

  • Promotion    –    It means that you capture the value present in the document (*.xml or wordML or you can   write your own document parser) and expose it to the SharePoint document library as a Column. What you get out of it is that you have a synchronization of the Data between the document and Column of the doc library. (When you update the document it gets automatically reflected in the document library and vise versa.) 
  • Demotion        –    It means the opposite. You capture the column of the Document Library and display it in the Document.    

Well whenever you publish a InfoPath form to the SharePoint server using File->Publish, at the end of the Wizard you will be provided

with a Option that will allow you to the add the field of the InfoPath to the document. How can do that when I automation the publishing of the InfoPath using features or When I publish the form using Central Administration Website?. There is an option in InfoPath, where you can specify the fields to be promoted to the Document Library at the design time. Use Tools->Form Option -> Property Promotion

 

 

 

 

Advertisements
  1. Matt
    October 31, 2008 at 1:59 pm

    When I do the above via Central Admin and then apply the content type to a form library, the properties I promoted do not appear in the library list. What else do I need to do?

    Thanks,
    Matt

  2. skurocks
    November 3, 2008 at 8:15 am

    Hi Matt,

    Have you checked the Columns list of the form Library?. I case if you are upgrading the form template you might run in to similar issue. But for the new Form and Form Library, it works like charm.

    There is no additional step you need to do other than that.

    Thanks & Regards
    Senthil

  3. Craig
    March 18, 2009 at 11:14 am

    Where is the demotion option? That would be quite handy for pulling a status value into the form.

    Also, I notice that after promotion, the column cannot be editied in the list settings. How then do I control options like formatting for the column? Try promoting a decimal form field that is used to hold currency and you’ll see what I mean. Also, promoted columns cannot have their values edited outside the form, even through workflow..is there a way around this?

  4. skurocks
    March 18, 2009 at 1:24 pm

    Hi Craig,

    It is by design.Promoted property column are read-only(Atleast in SharePoint UI).

    When you promote a property you have already arrived at a design that the user will be editing the Property value only through the other Application not though the SharePoint UI.Correct me if I am wrong.

    Also I promoted a Decimal Currency value to the List and I was able to see the same format retained in the list column as well [I entered 4,548.85 in InfoPath form and was able to see the same formated value in the list as well](I assume you have set the TextBox Properties to be of Decimal).

    If you want to edit the Promoted Property from the Code you need edit the xpath and update that back to the List.
    Below is the Snippet of code to do that.Soon I will come up with a post on this

    static void UpdatePromotedField(String sFieldName, String sFieldValue,SPListItem oListItem)
    {
    SPFile oFile = oListItem.File;
    //get the Stream out of the Memory Stream
    var msInfoPathFile = new MemoryStream(oFile.OpenBinary());

    //Build the Doucment out of the Stream content
    var oXmlDocument = new XmlDocument();
    oXmlDocument.PreserveWhitespace = true;
    oXmlDocument.Load(msInfoPathFile);

    //Name Space Manager
    var xmlNSManager = new XmlNamespaceManager(oXmlDocument.NameTable);
    xmlNSManager.AddNamespace(“my”, “http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-03-18T12:03:44”);

    //You Need to change the xpath as per the Structure of the your Document
    XPathNavigator oXPathNavigator = oXmlDocument.CreateNavigator();
    oXPathNavigator.SelectSingleNode(“/my:myFields/my:field1”, xmlNSManager).SetValue(sFieldValue);

    // the XmlDocument object back into SharePoint as a file.
    var myOutStream = new MemoryStream();

    oXmlDocument.Save(myOutStream);
    oFile.SaveBinary(myOutStream.ToArray());
    }

    Thanks & Regards
    Senthil

  5. Craig
    April 15, 2009 at 10:58 am

    Hi Senthil,

    You saw the number formatted as a decimal or as a currency? I want the column promoted as a SharePoint currency column, with 2 decimal places and a currency symbol. It only appears as a number, with no enforcement of 2dp and no symbol.

    Craig

    • skurocks
      May 6, 2009 at 5:48 pm

      Hi Craig, Sorry for the late reply I see the number as decimal. Let me post another post on how to get the value as the currency in the lib.

      Senthil

      • Craig
        May 20, 2009 at 9:50 am

        Hi Senthil,

        I look forward to your post on that topic!

        Craig

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: