RichText Control and Secondary Data Connection - InfoPath Dev
in

InfoPath Dev

RichText Control and Secondary Data Connection

Last post 01-25-2012 12:12 AM by Jimmy. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 01-23-2012 12:53 PM

    RichText Control and Secondary Data Connection

    Recently I ran into an issue with InfoPath form, I was displaying Rich Text data from an Second Data Connection(to a SharePoint library) in a Rich Text control(by setting its Default Value using a formula), they were rendered as plain text, all the formatting such as bullets, coloring, and font was lost.

     

    And the Rich Text data I mentioned above was collected using another InfoPath form and is displaying properly in its own form, could the process of promoting form field to content type/site columns remove the formatting?

     

    Have any one run into similar issue? How to get around this? Thanks for the information.

  • 01-23-2012 03:14 PM In reply to

    Re: RichText Control and Secondary Data Connection

    I found this old thread of this forum, which seemed to be a possible solution, but it isn't:

    http://www.infopathdev.com/blogs/greg/archive/2005/06/13/Display-Rich-Content-in-an-Expression-Box.aspx

     I opened the .XSN file and checked the View1.xsl file inside, the control is already using <xsl:copy-of select=my:field6/node()"/>, as seen here

                  <div><span hideFocus="1" class="xdRichTextBox" title="" tabIndex="-1" xd:binding="my:field6" xd:CtrlId="CTRL75" xd:xctname="RichText" xd:disableEditing="yes" style="OVERFLOW-X: visible; BACKGROUND-COLOR: #dce8ec; WIDTH: 100%; WHITE-SPACE: normal; HEIGHT: 36px; FONT-SIZE: small">
                    <xsl:copy-of select="my:field6/node()"/>
                   </span>
                  </div> 

  • 01-23-2012 09:58 PM In reply to

    Re: RichText Control and Secondary Data Connection

    Does the node datatype in the secondary data source show as richtext?  I suspect it is being recognized as a string field.  As long as it is recognized as a string field, copying the field value will lose markup.

    If you have imported an xml resource, there are ways to manually update the schema file so that it is seen as a richtext field and handled correctly.  It requires manually updating the resource file xsd in the manifest.xsf.

  • 01-23-2012 11:11 PM In reply to

    Re: RichText Control and Secondary Data Connection

    To the best of my knowledge, a default value formula cannot copy an entire node tree (and rich text is a node tree), so most likely the outcome of the default value formula is just the plain text portion of your rich text.  That is probably part of the issue you are encountering.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-23-2012 11:49 PM In reply to

    Re: RichText Control and Secondary Data Connection

    Hello again,

     How was the secondary data connection set up?  Is it an XML file data connection, or a SharePoint library data connection?  As Jim suggested above, it may be possible to modify the data connection's schema file to get InfoPath to recognize it as rich text.  This would generally consist of taking the field's definition:

         <xsd:element name="field1" type="xsd:string"></xsd:element>

    And replacing it with a rich text field definition:

       <xsd:element name="field1">
         <xsd:complexType mixed="true">
          <xsd:sequence>
           <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/1999/xhtml" processContents="lax"/>
          </xsd:sequence>
         </xsd:complexType>
        </xsd:element>

    There are some limitations to rich text controls bound to 2DSes.  They're read-only, and don't appear to support embedded images.

    If you would like to actually edit the rich text, this would require copying it into your main data source.  Our qRules suite provides the ability to copy rich text from one location to another quite easily, even between data sources using the CopyRichText command.

    One possibility to note is that depending on the type of data source you're using, the data being returned might not actually have the rich text in it in the first place.  One easy way to check this is to add a Calculated Value control that uses the following formula:

        count(xdXDocument:GetDOM("DataSourceName")/path/to/field//*)

    If this control always displays 0, then the field probably does not actually contain rich text. 

    Please let us know if the above suggestions help you get any more answers than you already have.

     

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-24-2012 09:48 AM In reply to

    Re: RichText Control and Secondary Data Connection

    Hi, Jim and Jimmy:

    Thanks for the replies. The Secondary Data Connection used by the Default Value Formula is a connection to a SharePoint Library.

    Basically we have two forms one called Project, one form called Proposal, there are an ID field and a Description field(Rich Text) on the Project form, and on the Proposal form we had a drop down to select which project this proposal is for, and when user selected a Project, the corresponding project Description was to be loaded into a read-only Rich Text control on the Proposal form just for displaying.....I was implementing this with the Default Value formula.

    If the Default Value formula would remove formating, what would be the other approach of doing this? Thanks,

     Wei 

  • 01-24-2012 10:26 AM In reply to

    Re: RichText Control and Secondary Data Connection

    If you want to copy the rich text into the main data source (which sounds to be the case) the only way to accomplish this is to use code or something that involves code.  As I mentioned earlier, qRules provides this functionality with the use of a simple command.  Would you happen to be using qRules in your form?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-24-2012 12:10 PM In reply to

    Re: RichText Control and Secondary Data Connection

    Kind of, the Description rich text data "copied over" from the secondary data source is for display only, no need to be persisted in the Proposal form.

    Thanks

  • 01-24-2012 12:25 PM In reply to

    Re: RichText Control and Secondary Data Connection

     Hi Jimmy,

     Looking at your qRules list, it looks like the CopyRichText command won't work with web Browser forms (http://www.qdabra.com/en/products/qRules_requirement.aspx).

    Thanks

  • 01-24-2012 01:31 PM In reply to

    Re: RichText Control and Secondary Data Connection

    @alberta

    If that's the case, then my suggestion in my earlier post (modifying the schema file) would probably be enough.  Before you do that, though, I would recommend doing the check I mentioned at the end of that post to make sure that the data connection is bringing in the rich text in the first place.

     

    @starkey

    I apologize for the error on our website.  The CopyRichText command is actually compatible with browser forms.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-24-2012 03:49 PM In reply to

    Re: RichText Control and Secondary Data Connection

    Jimmy,

    Here is how the schema looks like for the particular Rich Text Box control type i.e. in the secondary data source, which means there seem to be no issue:

    <xsd:element name="AISIProjectDescription">
            <xsd:complexType mixed="true">
                <xsd:sequence>
                    <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/1999/xhtml" processContents="lax"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

    I was trying to use the Calculated value by using the XPath you suggested above but I keep getting this as opposed 1 or 0. Do you have any idea why?

    The InfoPath message I am getting is "Function 'GetDOM' did not return a value, or it returned a value that cannot br converted to an XSL data type".

    This is how my XPath looks like:  count(xdXDocument:GetDOM("Cycle5Projects")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:AISIProject_x0020_Description//*)

     Thanks

  • 01-25-2012 12:12 AM In reply to

    Re: RichText Control and Secondary Data Connection

    If the schema's already all set up as it looks to be, then have you tried just creating a Rich Text Box bound to that field?  I would think that would work.

    One thing that's confusing me is the text you pasted from your schema has the field name as AISIProjectDescription and your XPath has AISIProject_x0020_Description.  Do you know why there's a discrepancy there?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.