HTML in the database

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

HTML in the database

  • Comments 2
  • Likes

It is a general rule that in CRM data fields are not supposed to hold HTML which can then be passed directly back to the interface.  This is by design.

So if you store a string in a text field like "<a href=></a>" then when this is rendered into the browser screen it is encoded so that the actual HTML produced will be

&lt;a href=;;/a&gt;

The same thing will occur in views and as a result of queries.

select '<a href='+comp_customurl+'>'+comp_customurl+'</a>' as comp_link, * from company where comp_companyid=28

The text sent to the interface will have been encoded.

&lt;a href=;;/a&gt;

Note:  Translations held in the custom_captions table are not encoded.  These may store HTML in them but this usage is generally discouraged as other better mechanisms are available for adding HTML tags and behavior into screens.

  • Does eWare or CRM have any functions to remove or strip off the html tags before passing information into the database?

  • It doesn't have any particular functions - but it does have the tools to allow you to format the inbound data in any way you like.  For example you could use Validation rules to block illegal tags or you could use a table level script to change the data on its way in.

    You could use regular expressions to process the data.

    Check out the articles that discuss regular expressions and also the article that discuss the Values() collection that in table level scripts can be reassigned.