It's all about the answers!

Ask a question

RTC customization of default values : Hyper link not working


Chethan Kumar M P (11) | asked Nov 15 '22, 6:39 a.m.

 Hello,

i have a default value script , where i'm trying to add a Hyperlink, but While adding i got "Class name is already declared by a different script" error in Tool (Eclipse). It doesn't reflecting in server.

Could you please support me here , on correcting my script and error in the Tool.

#################################################
dojo.provide("com.ibm.team.workitem.attribute.description");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");



(function() {
dojo.declare("com.ibm.team.workitem.attribute.description", null, {

        getDefaultValue: function(attribute, workItem, configuration) {

        var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
        var type = workItem.getValue(WorkItemAttributes.TYPE);

       
if(type == "analysis"){ 
return "Scenario: \n\n\n"+ 
"Current behavior: \n\n\n"+
"Expected Behavior: \n\n\n"+
"(Optional) Proposal for solution: \n\n\n"+ 
"(Optional) Workaround: \n\n\n"+"Template and fill out hints:"+
"<a href=https://inside-docupedia.bosch.com/confluence/display/Bodas/Analysis+work+item?                                         src=sidebar>" Analysis work item"</a>;\n\n\n";
 
}
});  
})();

################################
Default value looks like this as below
###############################
Scenario:


Current behavior:


Expected Behavior:


Version / Name:


(Optional) Proposal for solution:


(Optional) Workaround:


Template and fill out hints: Analysis work item 

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Nov 15 '22, 7:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 In case of naming conflicts change the name e.g. do not use com.ibm.team.workitem.attribute.description use my.custom.default.attribute.description.


It would be preferable, if the script was syntactically correct. The function/script must return a value. So fort all the other types you could either return an empty string, or another sensible default. Not returning anything is not correct.


Comments
Ralph Schoon commented Nov 16 '22, 4:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You also might want to consider https://stackoverflow.com/questions/1029781/what-is-exactly-the-meaning-of-in-javascript .

For the beginning consider to have a default value you pass if the match you do does not work, so you can see that the match fails. 

Consider debugging your script in the Chrome browser. 


Ralph Schoon commented Nov 16 '22, 4:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also check with https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Providing_new_customizations_imp 


The definition of var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; is in the scope of the function outside of the declaration if the function body. 


Ralph Schoon commented Nov 16 '22, 4:39 a.m. | edited Nov 16 '22, 5:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Finally, the only way I am able to create a clickable link in a work item attribute using Attribute Customization 


1: Using the built in special default value provider (not type aware) 
2: Using the work item attribute type Wiki this works also with JavaScript. See https://jazz.net/library/article/1093 last lab. 
3: Using an HTML work item attribute type only works with the Java API. See: https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ . It is necessary to use com.ibm.team.foundation.common.text.XMLString.createFromPlainText(String) or other methods from com.ibm.team.foundation.common.text.XMLString to make sure the Summry contains the correct format. With JavaScript you will see the tags in the summary but the tags will not work.  

Note that the built in default value provider are created in Java, so the HTML default values work correctly by using the class mentioned above.


Ralph Schoon commented Nov 17 '22, 10:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.