It's all about the answers!

Ask a question

Calculated script keeps resetting when you refresh Work Item


Jason Wilson (311326) | asked Jun 30 '17, 10:27 a.m.

Hi,

I am wondering if anyone on this forum is able to help me please.

I have created a script which updates a status read only field on a work item based on Agreed and actual date (Script below)

dojo.provide("com.example.KPIcalc");

(function() {
    dojo.declare("com.example.KPIcalc", null, {
       
        getValue: function(attribute, workItem, configuration) {
            var agreedDate = workItem.getValue("ID-FOR-AGREED-DATE-FIELD")   
            var actualDate = workItem.getValue("ID-FOR-ACTUAL-DATE-FIELD");
            if (agreedDate != null && actualDate == null) {
                //if agreed date and actual date are null, return UNASSIGNED
                //return "com.ibm.enum.kpistatus2.literal.l2";
                return "ID-FOR-KPI-STATUS-LITERAL-UNASSIGNED";
            }
            if (agreedDate != null
                    && actualDate != null
                    && agreedDate >= actualDate) {
                //if agreed date is not null, actual date is not null, and agreed date is after or the same as actual date, return COMPLETED ON TIME
                //return "com.ibm.enum.kpistatus2.literal.l4";
                return "ID-FOR-KPI-STATUS-LITERAL-COMPLETED-ON-TIME";
            }
            if (agreedDate != null
                    && actualDate != null
                    && agreedDate < actualDate) {
                //if agreed date is not null, actual date is not null, and agreed date is before actual date, return COMPLETED LATE   
                //return "com.ibm.enum.kpistatus2.literal.l6";
                return "ID-FOR-KPI-STATUS-LITERAL-COMPLETED-LATE";
            }
            //else return "in progress"
            //return "com.ibm.enum.kpistatus2.literal.l8";
            return "ID-FOR-KPI-STATUS-LITERAL-IN-PROGRESS";
           
        }
    });
})();

When I create a calculated script based attribute customisation and assign this to the applicable attribute on the work item it all works.

The status is correct populating dependent on the dates entered..

My issue......

When I fresh the work item or hard refresh (ctrl+f5) the status field resets getting rid of any value that was assigned. I then have to reset the dates for the status field to correctly populate.

Is there something I am missing that will stop a fresh resetting any calculation made on a workitem?

One answer



permanent link
Jason Wilson (311326) | answered Jul 04 '17, 6:16 a.m.

I think I have found the cause of this issue....

If (in RTC) you go the the attributes and at this stage you make the field READ ONLY (RO), the behaviour described in the question exhibits itself.

However it you do not make it a RO attribute, but instead navigate to the editor presentation and then make the presentation field RO, then the process works and a refresh of the screen no-longer causes the field to reset.

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.