How to script a bolded string in Script Based Default Value?
I am trying to put a bolded string as a Default Value for the Description field, but only for one work item. Therefore, I have to use Script Based Default instead of Multi-Line HTML. How do I need to return the string to get it to show up bolded in the Description field? The Description field is a Large HTML. Cntl+B in the text field manually will work.
I have tried:
1) return "<b>Bold this string</b>";
2) return <b>"Bold this string"</b>;
3) return <b>'Bold this string'</b>;
4) return '<b>Bold this string</b>';
5) var str = "Bold this string";
var bld = str.bold();
return str;
None of these work. My colleagues have not had luck either. There's got to be a way. Please help.
2 answers
As far as I can tell, the syntax is to return a string. Like
The Description attribute is of type large HTML. Technically the content syntax is HTML. So the return value would be "<b>bold text</b>". This will be the content of the description if you boldfaced the text.
However, this won't work. The description will show "<b>bold text</b>". The reason behind this is that the field is internally managed as XML. To set the XML field from a string, there are two methods. One is to create a valid XML from a plain string. This is the one that apparently has been used. The other one is to expect a valid XML and just put it in.
The method that has been chosen changes special characters like < and > into escape sequences. This allows to return something like "1 < 2" without causing an invalid content. Unfortunately the consequence is that you can't really return HTML syntax, because the tags will return with escaped < and > and this results in the result above.
The full HTML syntax that I am aware of is
However, this does not work with the method chosen for implementation. Instead
will result in a valid link, user mentions and work item link being created. This unfortunately does not allow to create breaks or bold face text however.
The chosen method allows user with almost no experience return their texts and can't corrupt the attribute value, however, It does not allow to use the full HTML syntax.
return "This is a string";
The Description attribute is of type large HTML. Technically the content syntax is HTML. So the return value would be "<b>bold text</b>". This will be the content of the description if you boldfaced the text.
However, this won't work. The description will show "<b>bold text</b>". The reason behind this is that the field is internally managed as XML. To set the XML field from a string, there are two methods. One is to create a valid XML from a plain string. This is the one that apparently has been used. The other one is to expect a valid XML and just put it in.
The method that has been chosen changes special characters like < and > into escape sequences. This allows to return something like "1 < 2" without causing an invalid content. Unfortunately the consequence is that you can't really return HTML syntax, because the tags will return with escaped < and > and this results in the result above.
The full HTML syntax that I am aware of is
return "Plain text<br/><b>bold text</b><br/><i>italic text</i><br/><a href=”https://jazz.net/forum/”>Forum Link</a><br/>User link to <b>@ralph </b><br/>Work Item link to Defect 3 <br/>"
However, this does not work with the method chosen for implementation. Instead
return "Plain text https://jazz.net/forum/”; User link to @ralph; Work Item link to Defect 3"
will result in a valid link, user mentions and work item link being created. This unfortunately does not allow to create breaks or bold face text however.
The chosen method allows user with almost no experience return their texts and can't corrupt the attribute value, however, It does not allow to use the full HTML syntax.