How do I use JavaScript with RTC 3.0.1
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.
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.***”?
Accepted answer
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
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