Skip to main content
Nintex Community Menu Bar

Nintex Workflow - Use Build String to create HTML

  • January 18, 2016
  • 8 replies
  • 223 views

Forum|alt.badge.img+7

I use a workflow to create some HTML that I store in a field on my list item.

I can do all kinds of stuff - for example create a table. Then when the list item is viewed, the nice table is shown in a field.

However - there is one thing that is somehow left out: I want my HTML to refer to a stylesheet, so the styling of the table can be dynamically changed later without having to re-run the workflow on all the list items. But my "<LINK REL ...." stuff seems to be ignored.

An example:

I have a list with a multiline textfield called "SomeHTML" and this workflow:

Untitled.png

Running the workflow on a list item results in this way - I can see the result of the two heading tags and they appear in the DOM viewer, but the "<LINK Rel..." has magically disappeared.

167301_pastedImage_1.png

How should I go about making a reference to a stylesheet in the workflow generated HTML?

Regards

Leif

8 replies

Forum|alt.badge.img+7
  • Nintex Partner
  • January 18, 2016

Well, the "easiest" solution would be to add the css in the form or the list view, instead of including the css reference in the content. This way you also include the css only once and not for every item.

So you could add a content editor webpart to the list view as well as to the display-form/edit-form to include the css.


Forum|alt.badge.img+9
  • January 18, 2016

LINK

This element defines a link. Unlike A, it may only appear in the HEAD section of a document

see Links in HTML documents


Forum|alt.badge.img+7

Hmmm, wouldn't that require me to go in and add the css in every list view that I have with this list? And furthermore if my users wanted to create a new view - for example to do some filtering or change of which columns to show - they would lose the styling?

Is there a way to include the styling in every view - including future ones?


Forum|alt.badge.img+7

I tried to write the styling as inline in stead of linking to an external file (which is not really my dream scenario but ok, just to try).

To keep things simple for this investigation, I just put this in the Build String action:

<style>table {background-color: red;}</style>

This did not give me red tables... When looking at the html code that is generated I can see that something more is added (by Nintex? or by Sharepoint itself?):

Untitled.png

This "magic number" makes it so my styling of tables is not rendering. I copied the above snippet to a text file, and when I removed the "magic number", the table suddenly appears with red background.

Where does this number come from? Can I get rid of it, or in some other manner get the browser to render my styling despite this number being there?


Forum|alt.badge.img+7
  • Nintex Partner
  • January 19, 2016

Good question.

Why don't you add a custom class to your table and add the styles using a content editor webpart to the page?


Forum|alt.badge.img+4
  • January 22, 2016

One of the things I've noticed while adding any kind of style in a nintex-workflow using 'build string' is that either SharePoint or Nintex adds line breakers directly in the html code.

The best way to avoid that is to remove all line breakers in the code inside the 'build string' command. I'm guessing this could help you too.

so for instance (not use how html code will react in this box...)

<style>

     table{ something:1px;}

</style>

This will render incorrectly, always

instead <style> table{ something: 1px;}</style>

will react exactly as foreseen.


Forum|alt.badge.img+17
  • Nintex Partner
  • December 23, 2016

‌ did you come to a conclusion on this? You will definitely run into the sharepoint display templates that will remove html it doesn't like. It may be easier to simply add classes to the html and not include any style tags in the field's value. But instead change the display template or JSLink for the list view so as to include your custom CSS file.


Forum|alt.badge.img+12
  • January 2, 2017

I've found this to be true as well in my past tinkering.