Calculated value script not returning the value.
Shwetha G (60●3●31)
| asked Dec 06 '16, 4:40 a.m.
edited Dec 06 '16, 5:31 a.m. by Ralph Schoon (63.5k●3●36●46)
Hi,
I have this dojo script, when i am jst trying to return a hardcoded value 35. but am not able to get the value to the attribute. here the attribute is : Tracks of type integer. I always get the default value filled as zero. dojo.provide("com.example.trackLink.formal"); (function() { dojo.declare("com.example.trackLink.formal", null, { getValue: function(attribute, workItem, configuration) { return 35; } }); })(); Could you please help me this. Thanks in advance. |
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Dec 08 '16, 4:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Dec 08 '16, 4:29 a.m.
You want to carefully read the documentation I sent you and understand the different types of attribute customization scripts and what you can access and what you can't.
Some more hints here:
https://jazz.net/library/article/1003
https://jazz.net/wiki/bin/view/Main/AttributeCustomization
https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/
You can not easily determine a state change in an attribute customization and you can not access links either. In order to do things like that you have to create a Java work item save advisor like https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/
Ralph Schoon selected this answer as the correct answer
Comments Some additional things:
|
2 other answers
Your script works fine. Go to the Attribute definition and make sure that: - The attribute type is Integer - You have selected the script in the 'Calculated Value' column.
Comments
Thanks a lot for your replies Miguel Tomico and Ralph Schoon
@Miguel Tomico, I had set the attribute's type to integer and also set the calculated script, but still it didnt work.
Today i tried with parsing the integer then the value was returned.
@Ralph Schoon, thanks for sharing the links, this is very helpful for me as a beginner.
I still need your help :
I have a problem definition :
Whenever I set a WorkItem(say Problem), to "Set done" state, there should be a calculated script that checks whether the problem is having a "Tracks" Link associated. If not present, then it should not allow the user to close the problem. (In short : Every Problem should have a defect associated with it, before closing it)
Are there any solutions for this ?
Currently I am trying out this steps:
1. have a hidden field in the Problem.
2. Have a calculated script that contains a oslc uri, that hits the RTC server and fetches all the "tracks " WI, it will return a xml containing all the WI along with count of how many WI linked.
3. In the calculated script, I will use a regular expression to get the counts of linked items returned. If it return zero
then no WI linked to that problem, so that value should be passed to the hidden field.
4. when the user is selecting the "set done" state, it should check this hidden field value, if it is set to 1 then it should allow the user to "set done" else restrict.
Is this the correct approach, else please suggest me the better approach to access the "Links" of a WI.
I am struck with this following steps :( could you please help me with this.
1. Is there any way I can access the links to a particulr workItem eg... "Contributes to", "Tracks" etc..from dojo ?
2. Can I use REST/OSLC URIs in DOJO to check the "Links" of a WI.
Thanks in advance.
Shwetha G
commented Dec 07 '16, 11:13 a.m.
@Ralph Schoon, thanks for sharing the links, this is very helpful for me as a beginner.
Shwetha G
commented Dec 07 '16, 11:15 a.m.
I also need your support for my following queries.. Please help me :)
I have posted it below
Thanks in advance
|
Ralph Schoon (63.5k●3●36●46)
| answered Dec 06 '16, 5:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You might want to look into this workshop: https://jazz.net/library/article/1093 especially https://jazz.net/library/content/articles/clm/2012/process-enactment-workshop/workbook/pew-rtc-lab-workbook.pdf . We have not done an example for an int but I would suggest to read it anyway. Also http://www.w3schools.com/ is a good first reference.
I'd try
var result = parseInt("35");
return result.
Comments
Shwetha G
commented Dec 07 '16, 11:39 p.m.
Hello Ralph,
|
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.