It's all about the answers!

Ask a question

Auto Calculate Field Input Values


R Z (1252539) | asked Aug 20 '19, 8:23 a.m.

Hi,


I have three fields F1, F2 and F3 which has integer properties.
I want to auto calculate fourth field F4 based on the values from these three fields F1 +F2+F3.
Can someone please share me the script.

Thank you

Accepted answer


permanent link
Ralph Schoon (58.0k23642) | answered Aug 20 '19, 8:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
R Z selected this answer as the correct answer

One other answer



permanent link
R Z (1252539) | answered Aug 21 '19, 7:33 a.m.

Thank you, Ralph. I created one script and it is working fine.

Now, my another requirement is the to update the new field F5 based on result F4.
F5 field is a enumeration based, low, medium and High.
Whatever value we get in F4, it should automatically map the corresponding value in F5.
Is it possible?
Another way is to mandate the field in work flow but again its a manual process.
Can you please help.
Here is the script what I have created
dojo.provide("com.example.f4");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
 
 (function() {
    dojo.declare("com.example.costToDate", null, {
 
    getValue: function(attribute, workItem, configuration) {
 
        try {
            var rate = parseFloat(workItem.getValue("defect.f1"));
            var hours = parseFloat(workItem.getValue("defect.f2"));
            var resource = parseFloat(workItem.getValue("defect.f3"));
 
            var f4; 
            f4 = f1 * f2 * f3
 
            return cost.toString();
        }
        catch(err) {
            var txt; 
            txt="There was an error on this page.\n\n";
            txt+="Error description: " + err.message + "\n\n";
            txt+="Click OK to continue.\n\n";
            alert(txt); 
        }
 
    }
 
    });
})();
 


Comments
Ralph Schoon commented Aug 21 '19, 7:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Read the Enactment Workshop Lab 3 and 4 at least, and https://jazz.net/wiki/bin/view/Main/AttributeCustomization . Yes, calculated values work for enumerations as well. Watch https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/ and be aware about the limitations. 


Be careful what you try to implement and question the requirements. 

Next time please ask another question, instead of answering a question to an accepted answer.

Your answer


Register or to post your answer.