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

JSON.stringify() and JSON.parse() seem to break calculated value scripts in RTC. How do I use JSON in calculated values?

Hi

I am tinkering with 'calculated values' in RTC trying to customize the behavior. I thought I'd store information as a JSON object in a 'Large String' custom attribute. However, it seems that as soon as I try to reference any of JavaScripts built in JSON functions the script no longer works.

For example, this script does not work. But it does print out "{}" in the console showing that the JSON function works.
dojo.provide("test_script");

console.log(JSON.stringify({}));

(function() {
dojo.declare("test_script", null, {
getValue: function(attribute, workItem, configuration) {
return "test script output";
       }
    });
})();
When I comment out the JSON parts it works fine:

dojo.provide("test_script");

//console.log(JSON.stringify({}));

(function() {
dojo.declare("test_script", null, {
getValue: function(attribute, workItem, configuration) {
return "test script output";
       }
    });
})();

The behavior is the same regardless of where I reference JSON. 'var a = JSON' anywhere will break it.
I do not get any errors when trying this as opposed to if the code contains null references.
Has anyone else encountered this problem?

Thank you for your time :)

0 votes



One answer

Permanent link
After googling for a bit I realized that I needed to import JSON from dojo. The following scripts works:

dojo.provide("test_script");
require(["dojo/json"], function(JSON){
	console.log(JSON.stringify({}));
dojo.declare("test_script", null, {
getValue: function(attribute, workItem, configuration) {
return "test script output";
       }
    });
});
I'll Just leave this here in case anyone else has the same problem.

0 votes

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
× 7,496
× 11

Question asked: Dec 16 '15, 4:34 a.m.

Question was seen: 4,878 times

Last updated: Jan 04 '16, 3:25 a.m.

Confirmation Cancel Confirm