[SOLVED] Calculate using pick list
Hello,
I am attempting to calculate using three different pick lists and am wondering if there is a better way to do this. The idea is to update a custom field GUDF_LONG3 using the information from GUDF_CHAR41, GUDF_CHAR42 and GUDF_CHAR43 added up together. Each of the pick lists has a value that starts with 0.0, 3.0, 5.0 and 8.0 with one exception being 1.5. These values need to be added together and input into GUDF_LONG3 which I have been able to do, by issues arise if the pick list is changed to a lower or higher value, I am not sure how to get it to recalculate.
- var brr=$CS.getText("GUDF_CHAR41");
- var tec=$CS.getText("GUDF_CHAR42");
- var cos=$CS.getText("GUDF_CHAR43");
- var risk1=$CS.getValue("GUDF_LONG3");
- var risk2='GUDF_LONG3';
- if (brr.startswith("0.0") ||
- tec.startswith("0.0") ||
- cos.startswith("0.0")
- ) {
- var risk3,risk4,risk5 = "0";
- }
- else if (cos.startswith("1.5")
- ) {
- var risk5 = "-1.5";
- }
- else if (brr.startswith("3.0") ||
- tec.startswith("3.0") ||
- cos.startswith("3.0")
- ) {
- var risk3,risk4,risk5 = "-3";
- }
- else if (brr.startswith("5.0") ||
- tec.startswith("5.0") ||
- cos.startswith("5.0")
- ) {
- var risk3,risk4,risk5 = "-5";
- }
- else if (brr.startswith("8.0") ||
- tec.startswith("8.0") ||
- cos.startswith("8.0")
- ) {
- var risk3,risk4,risk5 = "-8";
- }
- var risk6 = parseInt(risk3, 10) + parseInt(risk4, 10) + parseInt(risk5, 10);
- $CS.setValue(risk2,risk6);
New to ADSelfService Plus?