Skip to main content
Inspiring
September 13, 2023
解決済み

Help with Custom Calculations

  • September 13, 2023
  • 返信数 1.
  • 3681 ビュー

Hello,

 

I'm preparing a form that calculates a projects complexity based off of the project length and the number of utilities. The Project Length field will either be less than, greater than or equal to 1 mile and the No of UTs field would be a range of utilities. For example, a project with 7-10 utilities and a length of 1 mile or more would be a complexity level 7. I couldn't find a discussion where someone had the same problem.

このトピックへの返信は締め切られました。
解決に役立った回答 Badhawg66

This is not valid:

(this.getField("No of UTs").value >= 4 && <= 6)

You need to either use a variable, or repeat the full statement for each condition, like this:

(this.getField("No of UTs").value >= 4 && this.getField("No of UTs").value <= 6)


I wish I knew how to use variables but this script seems to work just fine. Thank you for your help!

 

if((this.getField("No of UTs").value == 1))
{
event.value = 1;
}
if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value <= 3))
{
event.value = 2;
}
if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value >= 3))
{
event.value = 3;
}
if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 4))
{
event.value = 4;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 5))
{
event.value = 4;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 6))
{
event.value = 4;
}
if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 4))
{
event.value = 5;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 5))
{
event.value = 5;

}
if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 6))
{
event.value = 5;
}
if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 7))
{
event.value = 6;

}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 8))
{
event.value = 6;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 9))
{
event.value = 6;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 10))
{
event.value = 6;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 7))

{
event.value = 7;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 8))

{
event.value = 7;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 9))

{
event.value = 7;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 10))

{
event.value = 7;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 11))
{
event.value = 8;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 12))
{
event.value = 8;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 13))
{
event.value = 8;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 14))
{
event.value = 8;
}

if((this.getField("Proj Length").value < 1) && (this.getField("No of UTs").value = 15))
{
event.value = 8;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 11))
{
event.value = 9;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 12))
{
event.value = 9;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 13))
{
event.value = 9;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 14))
{
event.value = 9;
}

if((this.getField("Proj Length").value > 1) && (this.getField("No of UTs").value = 15))
{
event.value = 9;
}


if((this.getField("No of UTs").value >= 15))
{
event.value = 10;
}
else
{
// do nothing
}

返信数 1

try67
Community Expert
Community Expert
September 13, 2023

You need to better define the formula for this calculation...

> The Project Length field will either be less than, greater than or equal to 1 mile

So basically, any possible value...

> and the No of UTs field would be a range of utilities.

Not very descriptive...

> For example, a project with 7-10 utilities and a length of 1 mile or more would be a complexity level 7.

Why? What's the formula to arrive to that? Why not 10? Why not 8? Is it the product of the length by the number of utilities? What's the cut-off? A lot of info missing there.

Badhawg66作成者
Inspiring
September 13, 2023

I apologize for being so vague. I'm trying to get rid of this cheat sheet I use. I'm hoping there's a way to make a script or multiple scripts that will help us figure out the complexity based off of the project length and number of utilities.

try67
Community Expert
Community Expert
September 14, 2023

I still don't understand how these values are specified by the user. Are you using a drop-down?

Can you share the actual file?