It's all about the answers!

Ask a question

Script based attribute customization: possible to return formatted text?

Steve Willems (8811311) | asked Jul 16 '13, 11:44 a.m.
edited Jul 17 '13, 7:42 a.m.
 Using the Default Value based attributes customization (Script based) I can add a default text in the  descripiton based on the work item type. 
This is working fine, however to make it nicer (as possible with the Multiline text) I would like to add some basic formatting. 

Does anyone have an idea if thisis possible and how?

Thanks a lot

Here's a short example of the js
(function() {
	var instructions= {
		"defect": "<b>1.Summary:</b> Fill in a nice and clear description"
	var WorkItemAttributes=;
    dojo.declare("scripts.DefaultDescription", null, {

        getDefaultValue: function(attribute, workItem, configuration) {
			var type = workItem.getValue(WorkItemAttributes.TYPE);
			var instruction = instructions[type];
			if (instruction == null) {
				return "";
			} else {
				return instruction;

3 answers

permanent link
sam detweiler (12.5k6195201) | answered Jul 16 '13, 11:57 a.m.
the summary and description fields are not HTML, so HTML tags won't work.

Steve Willems commented Jul 17 '13, 7:41 a.m.

both summary and description are medium and  large HTML type attributes

permanent link
Indradri Basu (1.8k1514) | answered Jul 17 '13, 7:28 a.m.
Hi Steve, your idea is fine and to add multiline text in the default value string you can use \n for new line or line breaks. Something like :
var value = "This is the 1st line \n2nd line..."
return value;

Should give you :

permanent link
Steve Willems (8811311) | answered Jul 17 '13, 7:39 a.m.
edited Jul 17 '13, 7:41 a.m.
Thanks, I knew it was possible using new line but it would be nice to use also some bold items for titles/sections in the  description.

When you take a look at what is save in the process description when using a default value (multiline html) this is what you get so I guess somehow it should be possible to send this also back in an understandable format for the description (which is of type multiline HTML) using the script:

<defaultValueProvider id="" name="Guidelines User Story" providerId="">
<value content="&lt;b&gt;1.Summary:&lt;/b&gt; use a good subject line that is clear and concise.&lt;br/&gt;&lt;br/&gt;&lt;b&gt;2. Description:&lt;/b&gt; Make sure the description contains all steps required to finish the implementation of the User Story and fully describes what is requested.&lt;br/&gt;&lt;br/&gt;&lt;b&gt;3.Acceptance criteria:&lt;/b&gt; Make sure to put the conditions on which the story is considered as completed. It is very important here to described what is (or what is not) included so a tester can set it as verified. Typically here you will find also the links towards test cases validating the User Story."/>

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.