It's all about the answers!

Ask a question

Script is not working in web ui, In eclipse working fine


Anurag Patel (21363) | asked Jun 16 '16, 9:16 a.m.
edited Jun 17 '16, 6:42 a.m.
Hello All,

I implemented simple script but it is not working in WEB UI, In eclipse it is working fine.
I took attribute of pushedValue and multiselect of type "medium string". which can select multiple values from the list.

When we run the script then it is working in eclipse but not in WEB.
Can any one know why reason of this issue .



Comments
Anurag Patel commented Jun 16 '16, 9:24 a.m. | edited Jun 17 '16, 1:58 a.m.
 Please follow below script
-------------------------------
dojo.provide("org.example.workitems.providers.pushedValueOfXML");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.pushedValueOfXML", null, {
    getValueSet: function(attributeId, workItem, configuration) {
var pushedValue = workItem.getValue("com.ibm.team.workitem.attribute.pushedvalue");
var multiselect = workItem.getValue("com.ibm.team.workitem.attribute.multiselect");
var SplitedString = multiselect.split("|");
var allData = [];
var block = ["block-1","block-2","block-3","block-4","block-5"];
var EDZ = ["EDZ-1","EDZ-2","EDZ-3","EDZ-4","EDZ-5"];
var GP = ["GP-1","GP-2","GP-3","GP-4","GP-5"];
for(var i=1; i<SplitedString.length-1;i++)
{
if(SplitedString[i].equals("block"))
{
console.log("In block ..."); 
for(var count = 0; count <block.length; count++)
{
allData.push(block[count]); 
}
}
else if(SplitedString[i].equals("EDZ"))
{
for(var count = 0; count <EDZ.length; count++)
{
allData.push(EDZ[count]); 
}
}
else if(SplitedString[i].equals("GP"))
{
for(var count = 0; count <GP.length; count++)
{
allData.push(GP[count]); 
}
}
}
        return allData;
    }
});
})();

6 answers



permanent link
Donald Nong (14.5k414) | answered Jun 17 '16, 2:15 a.m.
I don't spot anything that would work in Eclipse only but not in a browser. If it fails, it should fail in both cases. When you step through SplitedString[], you start at 1 (instead of 0), and stop before length-1 (instead of length), is it by mistake or intentional (assuming the first and last elements need to be filtered out)?

Also, it's mentioned many time on this forum - elaborating what "is not working" means goes a long way for others to help you.

P.S. The variable pushedValue never gets used in the script. Why?

Comments
Anurag Patel commented Jun 17 '16, 4:35 a.m. | edited Jun 19 '16, 8:54 p.m.

 Hi Donald,


Thanks for your reply.
About SplitedString[] gives the output like [,"block ","EDZ ","GP ",]
0th and last value of array is blank ""/null.
pushedValue varible is not used in the script.

I am trying to implement if I select the block  and EDZ  from string list type of attribute (multiselect attribute) then in other string list type attribute/ medium string/ in enumeration I want all the values which are defined in array of block  and EDZ.

I implemented and tested in eclipse. It gives the exact result as per the requirement but in web ui in it gives blank data. Tested in all browser.


Thanks & Regards


sam detweiler commented Jun 17 '16, 8:25 a.m.

so, add some logging and see what is different when using the web UI.


permanent link
Ralph Schoon (63.1k33646) | answered Jun 17 '16, 8:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see https://rsjazz.wordpress.com/2016/06/17/javascript-attribute-customization-where-is-the-log-file/ to find the log files and for the hints for using a debugger.

Comments
Anurag Patel commented Jun 20 '16, 3:23 a.m.

Hi Ralph,


I check .log file in eclipse metadata folder. It is not showing any error.
However found one error in browser while debugging :

Errror : ?include=D~&etag=F2mgQBZMdty_en_GB&_proxyURL=%2Fccm&ss=Iyg0p&locale=en-gb:22045 Uncaught Error: com.ibm.team.repository.web.transport.ServiceRequest(): invalid requestParameters parameter: [object Object]




Donald Nong commented Jun 20 '16, 3:35 a.m.

Use console.log() to get more detailed information. For example, print out the string before and after split.


Anurag Patel commented Jun 20 '16, 4:20 a.m.

Hi Donald,


I tried with same using console.log() and also alert(), but when we debug it in browser then the control is not going to the script and also it is not showing the printed values using console() and alert() method and gives the above mentioned error.
While if I do it same in eclipse using console.log then it shows the correct values and script also working fine.


Thanks


Ralph Schoon commented Jun 20 '16, 4:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Did you use ?debug=true and did you follow the link to understand the log locations?


Anurag Patel commented Jun 20 '16, 6:07 a.m.

Yes Ralph I tried by using ?debug=true in url.

Also checked the .log file on server and found that values are not coming for the attribute "multiselect " attribute. So that "SplitedString"  values also null.
But in eclipse these values are coming for both the attribute. Why facing this issue? Did you have any idea to resolve this problem. 


Ralph Schoon commented Jun 20 '16, 6:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I don't have an idea why your script fails, however,

  1. Make sure that the scripts can work with null values and not totally fail.
  2. Consider using a sensible custom ID schema e.g. use "customer.attribute.name" instead com.ibm.team.workitem.attribute...... this is likely not a problem, but nevertheless, you don't want to collide with a namespace you don't control, so pick your own.
  3. I am not sure what the multiselect attribute represents (type etc), since this information is missing. I am not aware of any attribute type that is separated using the pipe symbol.


showing 5 of 6 show 1 more comments

permanent link
Anurag Patel (21363) | answered Jun 20 '16, 7:01 a.m.
 Hi Ralph,

Thanks for reply. 
"Multiselect" attribute information :
Attribute Name : Multiselect
Id : com.ibm.team.workitem.attribute.multiselect
Type : String List
this attribute shows the list of data as : blockEDZ, GP, etc  
You can select multiple data same time.
I separated the data from attribute "Multiselect" and stored into array of name "SplitedString" of attribute. 
But problem is that when I select the multiple values from Multiselect attribute, and try to read the data it shown null data. And if run same script in eclipse then this data is coming in eclipse. it shows the data in Multiselect  as well as in SplitedString of attribute.

I am trying to read more than one value from the attribute. 





permanent link
Ralph Schoon (63.1k33646) | answered Jun 20 '16, 7:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
It is widely ignored but https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript states the work item attribute types that are supported. And it does NOT mention lists at all.

So from my perspective list attribute types such as stringList or other list types are not supported. So you are lucky you get something in Eclipse, but that does not necessary mean that this is supposed to work that way everywhere.
 

permanent link
Anurag Patel (21363) | answered Jun 20 '16, 8:37 a.m.
Hi Ralph,

Thanks for the reply.
My requirement is that,
In Task workitem there is one attribute (with name Project Name) which contains the project list like block, EDZ, GP etc. 
User can able to choose multiple values from "Project Name".
Below is the data related to Projects:

Projects List : block, EDZ, GP
Dependent values on projects :
    Block = block-1, block-2, block-3, block-4, block-5;
    EDZ = EDZ-1, EDZ-2, EDZ-3, EDZ-4, EDZ-5;
    GP = GP-1, GP-2, GP-3, GP-4, GP-5;

If user can select the Project Name Block and GP then there should be other attribute which will show the combined values of only selected projects (related to Block and GP) like block-1, block-2, block-3, block-4, block-5, GP-1, GP-2, GP-3, GP-4, GP-5
It should not show the values related to EDZ because EDZ is not selected in Projects.

Do you have any other solution which will implement above mentioned logic.
If yes then please suggest the attribute type which will select multiple values from the attribute and how to make dependency for Project Name and their dependent values.


permanent link
Ralph Schoon (63.1k33646) | answered Jun 20 '16, 8:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If you need more access to the work item API than the JavaScript API provides, you can look into https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ . This API is less limited. In some cases a follow up action that calculates and sets the values might be valid as well.

I can not provide you with more than this guidance.

Your answer


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