How to calculate two choice field values and populate in another field.

venkat Y
Tera Contributor

 Each of the field values need to have the following points assigned to each value for the calculation

a. Capability
1. Low = 1 point
2. Medium = 2 points
3. High = 3 points
b. Associates
1. < =100 = 1 Point
2. 101 to 1,000 = 2 Points
3. 1,001 to 10,000 = 3 Points
4. 10,001 to 50,000 = 4 Points

calculation should sum up the associated points for each value selected in capability, Associates fields

The "Effort " field needs to be a calculated field based on two other fields which are mentioned, and populate these choice depend on calculation

  1. a.  Not Prioritized - 0 points
  2. b.  Low - less than or equal to 5 points
  3. c.  Medium - greater than 5 points but less than or equal to 9 points
  4. d.  High - 10 or higher points

 

1 ACCEPTED SOLUTION

anubhavritolia
Giga Sage

Hi @venkat Y 

 

You can create Choices of field as below:

 

AnubhavRitolia_0-1668271625946.png

AnubhavRitolia_1-1668271662363.png

 

Then you can write below code in your 2 onChange Client Script for Capabilities and Associates field:

 

var cap = parseInt(g_form.getValue("u_capability");
var ass = parseInt(g_form.getValue("u_associates");
var eff = cap+ass;

if(eff==0)
{
g_form.setValue('u_effort','Not Prioritized');  // value of choice 'Not Prioritized'
} else if (eff<=5) {
g_form.setValue('u_effort','Low');  // value of choice 'Low'
} else if (eff>5 && eff<=9) {
g_form.setValue('u_effort','Medium');  // value of choice 'Medium'
} else if (eff>10) {
g_form.setValue('u_effort','High');  // value of choice 'High'
}

 

 

 

 

View solution in original post

7 REPLIES 7

Murthy Ch
Giga Sage

Hi @venkat Y 

You can use onchange client script on both capability and assocaites field.

//for setting the value in Effort field use below logic:
if(parseInt(g_form.getValue("capability") + parseInt(g_form.getValue("associates") <=5)
{
g_form.setValue("effort",Low);
}
....
..
//follow the same logic for rest of the options

Hope it helps:)

 

@Murthy Ch Thanks for the solution, but How to assign points to those choices to read  and is it possible in one script?

Hi @venkat Y 

It is possible in one script.

For assigning the points to choices you can do like below if you are using choice type field.

MurthyCh_0-1668268495610.png

So that it will give choice values when we are using g_form.getValue("fieldname") in client script.

 

 

 

@Murthy Ch these choices are reference choices..,and how choice values act like points..