You are viewing limited content. For full access, please sign in.

Question

Question

Retrieve Business Process Variables - Rich Text

asked on July 19, 2021

If we look at the data in the Rich Text variable from the variables tab under Monitor in Forms, we can see the variable contains specific text. However after retrieving into workflow, there is extra characters that look like this:

 <p><p>

Where do these extra characters come from?

0 0

Replies

replied on July 20, 2021

RTF fields are just HTML.

What version of Workflow are you using? Support for rich text fields is only available in 10.4 or higher.

0 0
replied on July 20, 2021

This is on a fully updated 10.4 build using the last 10.4.3 package.

They built a workflow to successfully retrieve the values, but these characters come over in areas where there are line returns, this doesn't look like HTML to me. When we look at the HTML we see things like <p> and <br>

0 0
replied on July 20, 2021

The data transfer from Forms to Workflow is done as XML, so the values have to be encoded.

Where are you using them in Workflow?

0 0
replied on July 20, 2021 Show version history

They are using the EncodeXML function on the resulting data, but it doesn't remove these funky characters.

They were trying to copy the data from one form to another, by first copying the data to a database nvarchar(max) field and then using a Lookup to retrieve it again.

I have reviewed the data as it comes across, these funky characters appear both before and after they EncodeXML on it.

The use case is to have a user task where the Rich Text object holds an offer letter template which can be edited in the task before sending to a candidate. Then the candidate is sent a link to a public form where they can read and either accept or reject the offer.

0 0
replied on July 22, 2021

I discovered some more information on this. EncodingXML still leaves the characters in, but if you configure a lookup to put the information into a standard Multi-Line field the characters are converted to their respective line returns and other formatting options.

There are just some characters that are not being converted, specifically &lt;div&gt;
&lt;/div&gt;

I am not sure what language this is or what these characters are meant to represent.

Typically XML looks like this

1 0
replied on July 23, 2021

Running EncodeXML on text that's already XML-encoded will not revert the encoding.

I took a second look at what we're doing and we're not converting those tags.

XML can contain text that's also been made  URL-safe. For ex, if you have rich text like this in Word:


the underlying values look like this

<p class=MsoListParagraphCxSpLast style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:
Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]>Bullet 3</p>

So it really depends on where the data is coming from.

As a side note, nvarchar will also save your value as HTML code, not the formatted display value. So you'll need to worry about displaying it when you read it.

 

0 0
replied on July 24, 2021

Oh wow, here is what they were doing in the javascript tab.

$(document).ready(function(){
      $('#Field35').change(function(){
        	$(this).val($(this).val().replace(/&lt;p&gt;&lt;b&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;\/b&gt;/g,''));
        	$(this).val($(this).val().replace(/&lt;b&gt;/g,''));
        	$(this).val($(this).val().replace(/&amp;nbsp;/g,''));
            $(this).val($(this).val().replace(/&lt;\/p&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;br&gt;/g,'\n'));
            $(this).val($(this).val().replace(/&lt;p&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;ul&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;li&gt;/g,'\n'));
            $(this).val($(this).val().replace(/&lt;\/li&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;\/ul&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;div&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;\/div&gt;/g,''));
        
        	$('#Field55').val($('#Field35').val());
      });
});

I added the 2 lines

            $(this).val($(this).val().replace(/&lt;div&gt;/g,''));
            $(this).val($(this).val().replace(/&lt;\/div&gt;/g,''));

The problem with this solution, is anytime they make changes in the Rich HTML template, they might add more formatting that javascript is not ready to replace. Also I was looking at some of the offer letters and there are random words without spaces between them. Spacing and punctuation errors in an offer letter is a terrible first impression.

I am thinking it would make more sense to just put it back into a Rich HTML field instead of a text area.

However when I try to hook the lookup to a read-only Rich HTML box, Forms will not let me choose my object, it is missing from the list of objects on the form.

So I thought, what about a Custom HTML object? That can read HTML. Well again the lookup will not let me populate this object. If the Rich Text is HTML and I need to put that back into an HTML object why can't I select any HTML objects?

Now I came up with this javascript workaround, which gets the data formatted and put into a Custom HTML object and it looks FANTASTIC. It now brings over even the Bold characters and all the work they did to create a nice looking offer letter.

        var decoded = $("<div/>").html($(this).val()).text();
        
        $('.offerOutput').html($.parseHTML(decoded));

However when I save it to the repository, it wipes out the entire custom HTML object. I thought Chromium fixed these issues by grabbing a snapshot of the form submitted instead of re-running the javascript in a bad frame.

I understand it's always risky using javascript but I can not put the Rich Text HTML back into a Rich Text object because it does not appear in the list. I think this is the fundamental problem they are running into.

For now what I will do is show them the great looking HTML on the form and save the crappy looking text area to the repository.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.