How do I use JavaScript with RTC 3.0.1
Bob Ferguson (89●15●44)
| asked Dec 28 '15, 9:03 a.m.
retagged Jan 20 '16, 9:24 a.m. by Ken Tessier (841●1●7)
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.
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
Bob Ferguson selected this answer as the correct answer
Comments
Bob Ferguson
commented Feb 08 '16, 9:07 a.m.
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");
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.
sam detweiler
commented Feb 08 '16, 9:34 a.m.
I think the log call must be INSIDE the function
Bob Ferguson
commented Feb 08 '16, 11:17 a.m.
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.
sam detweiler
commented Feb 08 '16, 11:26 a.m.
the log in eclipse is in eclipse_workspace_name/.metadata/.log
|
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.