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

RTC Scripting - Use an XML file as data source

Hi,

I have been developing some scripts to customize my work items for a few days/weeks now and thanks to this forum I have learnt a lot :)

However I am facing an issue to which I cannot find an answer.

I have several custom attributes which are linked and I would like to auto-update some of them according to another one.

To be more specific :
- I have a list of requestors (about 300 people)
- Each requestor is bound to a location and a cross asset
- I would like to set up automatically the location and the cross asset as soon as a requestor is selected. (The best would be to be able to select several requestors. So far I have a multi-select list in my editor but it is not very user-friendly to have 300 items in it so I am open to any suggestion and I will probably create a new post for that too.)

At first the requestor list contained only 50 people so I wrote 2 "calculated value" scripts in which I mapped each user to either its location or its cross asset and I updated the value this way.

Now that the list has expanded a lot, I think the best way would be to have an xml file in which would have the following structure :

<xml>               
    <node>               
        <id>1</id>   
        <name>Requestor 1</name>
        <crossAsset>Cross asset 1</crossAsset>
        <location>Loc1</location>
    </node>       
....
</xml>


Is there a way to "call"/load this xml file and manipulate it using dom in a script ?

Thank you

Gilles

0 votes



3 answers

Permanent link
You could try to use the HTTP filtered value provider if the XML is published on a HTTP server. I know you can't use it to just read the file. You could store the data you need for post-processing in this attribute. If you use this, you would probably have to create some script that, based on the data in the field calculates values for the other attributes. I have seen limitations on list type attribute values with scripts, so I can't tell if it would work for you.

The Scripts can access XML data in the process configuration. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_Example . I am no sure there is a way to access XML files from java script. I would be interested to know, if one has built a working solution..

0 votes

Comments

We developed pre-condition for RTC 2.0. which reads its configuration from process template source xml. So it's realizable using Java SDK for sure.


Permanent link
Hi Ralph,

Thank you for your quick answer.

I tried to use the HTTP filter value provider but I was not able to publish the XML on a HTTP server.

I finally managed to do something else :

- I created a "Value Sets" script called "ValueSetProvider". This script returns a multidimensional array in which all the info are available
var users = [   ["Name1", "Location1", "CrossAsset1"], 
                ["Name2", "Location2", "CrossAsset3"],
                ..... ]; 

- I created another "Value Sets" script called "ValueSetFiltering" which includes the "ValueSetProvider" script defined earlier, I am them able to define a new object which type is ValueSetProvider. In this "ValueSetFiltering" script I take advantage of the "Filtered" property and I am then able to filter the names just as I wanted to do. Besides I can always use the  ValueSetProvider object in other scripts in order to validate/invalidate some info.

0 votes

Comments

From a lab that is going to be published with the Process Enactment Workshop soon:

  • You can publish your own data easily using Apache. Install Apache as described in this article and place an XML document into the folder <Apchae-Install_Dir>/htdocs. You can also provide a different folder as described in the article mentioned above.


Unfortunatley I cannot install anything on my machine. My work environment is very restricted :(


Permanent link
Ok well, apparently that works in the Eclipse Client but not on the web client (neither on IE nor on FF).
Since I added the Value Sets scripts, I always receive an error message when creating a workitem>

Picture is attached below



The strange thing is that the error occurs on a Validator script which used to work perfectly. Code is given below :

dojo.provide("SED.Validator.Location");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
(function() {
var Severity=com.ibm.team.workitem.api.common.Severity;
var Status= com.ibm.team.workitem.api.common.Status;
dojo.declare("SED.Validator.Location", null, {
validate: function(attribute, workItem, configuration) {
                        var nbAvailableLocations = 8;
			var value = workItem.getValue(attribute);
			var values = value.split(",");
			if (value.indexOf("l6") != -1)  // i.e. "All" is selected
			{
				if (values.length > 1){
					return new Status(Severity["ERROR"], "If \"All\" is ticked, other values should not be selected")
				}
				return Status.OK_STATUS;
			}
			else if (values.length == nbAvailableLocations) {
				return new Status(Severity["ERROR"], "Select \"All\" instead of ticking all other values")
			}
			return Status.OK_STATUS;
        }
    });
})();


Is there a problem with Value Sets scripts ? (I am working on RTC 3.0.1.1 and as I have tested that on IE 7 and Firefox 16.0.2)

EDIT : Actually all my previous scripts do not work anymore and I get a similar error message as soon as a script is triggered

0 votes

Comments

I have never seen an error like that  - ever - when running a script customization.

I assume scripting is on. Try to delete the attachment from the projects process attachments (LinksTab and right lover editor in Eclipse Project Area Editor) and try to reload it.

Otherwise, are you using process sharing and have uploaded it in the shared project?

There are also many fixes that went into scripting when going to 4.x. 

Yes I already tried to delete and reload attachments but I still get the same errors.

I am not using process sharing ("Do not share this project area's process" ticked in Overview tab => Process Sharing in Eclipse)

If you manage the project area in the web UI and look for Process Sharing and that shares the process from another project area you are using this feature. I have heard about some at least in 4.x with customizing the process in certain situations. However,it is just a shot into the blue.

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
× 10,935
× 369
× 152
× 31

Question asked: Nov 21 '12, 7:03 a.m.

Question was seen: 7,734 times

Last updated: Apr 08 '13, 12:48 p.m.

Related questions
Confirmation Cancel Confirm