Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How do I use JavaScript with RTC 3.0.1

I am using RTC 3.0.1 and have a need to enforced work item validation for customized attributes.  I have to make 1 field required if another field has a certain value.

I have researched this and found out that it is possible using JavaScript.  I do not know Java but I am currently researching about it.

The following is the link that I found, it contains example of what I need, I do realize that I will have to modify it.

 https://jazz.net/help-dev/clm/topic/com.ibm.team.workitem.doc/topics/t_configuring_dynamic_required_attributes.html

 

I have a couple of questions about this.

 

When I select “Conditions” from “Attribute Customization”, I have to select “Script Based Condition” from the Provider drop-down list.

This will display a form for the Details of the JavaScript.

 

Name – Is this the name of the file minus .js?

Local File Path – Is this a full path that includes drive letter?

Local File Path – Does this path have to be shared so that all users have access?

Attachment Path – What is this?

Class Name – Do I use “org.example.***”?

 

0 votes


Accepted answer

Permanent link

I have a couple of questions about this.

When I select “Conditions” from “Attribute Customization”, I have to select “Script Based Condition” from the Provider drop-down list.


correct, it is the only choice


This will display a form for the Details of the JavaScript.


Name – Is this the name of the file minus .js?

              its the logical name of this condition.. call it anything you like.  doesn't have to be related to the filename. this is the name of the available conditions that will be listed in the advisor configuration


Local File Path – Is this a full path that includes drive letter?

              yes, this is where to load the script from/save it to, on the local system


Local File Path – Does this path have to be shared so that all users have access?

              no, the script will be loaded into the project area, so it can be executed by all users

              only used while you are editing the script locally


Attachment Path – What is this?

              the path into the project area storage


Class Name – Do I use “org.example.***”?


              whatever you want.. but this name MUST match the classname used in the script.

              I always tell my customers to use a naming convention that identifies who created the script

              I use com.sd.scripts.condition_name


Bob Ferguson selected this answer as the correct answer

0 votes

Comments

I believe I did everything correct however, it still does not work.  I have changed my script to be bare bones.  The following is my script:

dojo.provide("org.example.workitems.providers.policy-type_req");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
console.log("**********I am Here*********");
(function() {
 return false;
    }
})();

whether I return true or false the script does to stop a work item from being saved.  Also I never see anything in my eclipse client showing me the console.log.

I did create a dynamic required attribute pre-condition specifying this java script.  I will put logic to it after I can force it to fail.

I think the log call must be INSIDE the function

console.log("*I am Here**");

you may be causing an error which prevents the script from running
did you push the 'fill in example' link to get the initial code?

I am using RTC 3.0.1.  It does not have fill in example but it does have download sample.  I did the download and looked at the sample.  I did not have the dojo.declare.  I put that in and now a simple pass fail works.  Now I need to change it to look for a specific value of a field that is enumeration.

Note: I moved the console.log inside the function and it still does not work or I am looking in the wrong place for the log.

the log in eclipse is in eclipse_workspace_name/.metadata/.log

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 1,381

Question asked: Dec 28 '15, 9:03 a.m.

Question was seen: 2,920 times

Last updated: Feb 08 '16, 11:26 a.m.

Confirmation Cancel Confirm