Skip to main content
Alliosaaa
Inspiring
August 2, 2017
Question

Trouble with Displaying Button

  • August 2, 2017
  • 1 reply
  • 429 views

Hello!

I am running into issues and I can't seem to figure out why.

I'll try to write this simply... I am working on a paperwork package for a dealership to handle multiple vehicles sold at once. I have a couple line items that are divided evenly amongst all vehicles sold. If it is NOT able to be divided evenly, the remainder is calculated and added or deducted from the first vehicle sold. That is all working just fine. My problem is here... If the item is not divided evenly, a warning icon appears next to the line. This is the function I have written:

function warning(TotalField,PerField)

{

var PerName = event.target.name

var PerRounded = round(PerField,2);

var Count = this.getField("SOLD_COUNT").value;

var Offset = PerRounded * Count;

if ((Offset == TotalField) || (Offset == 0))

this.getField("WARNING_" + PerName).display = display.hidden

else

this.getField("WARNING_" + PerName).display = display.visible

}

The function seems to be working backwards.  I want the icon to appear ONLY when Offset does not equal TotalField, but it appears when they are equal and disappears when they are not.

Any ideas??

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 2, 2017

From what context are you calling this function, and what values are you supplying to it as its parameters?

Alliosaaa
AlliosaaaAuthor
Inspiring
August 2, 2017

Here is some more info:

I have a line item applied to each vehicle called "PAYOFF_PER". This is calculated by taking the field "TOTAL_PAYOFF" and dividing it by the number of vehicles sold ("SOLD_COUNT").

Let's say TOTAL_PAYOFF is $5,000.00 and I'm selling 3 vehicles, making PAYOFF_PER 1,666.67 (rounded up). As 1,666.67 * 3 = 5,000.01, I want to alert the user here that the first vehicle will reflect a 1 cent deduction on the Payoff line.

The function in question is called from a validation script of PAYOFF_PER:

var total = this.getField("TOTAL_PAYOFF").value; // in this example: $5,000

var per = this.getField("PAYOFF_PER").value; // in this example: $1,666.6666666666(repeating)

warning(total,per);

Now the function (document level script) which *should* display button ("WARNING_PAYOFF_PER").

function warning(TotalField,PerField)

{

var PerName = event.target.name // in this example: PAYOFF_PER

var PerRounded = round(PerField,2); // in this example: 1,666.67

var Count = this.getField("SOLD_COUNT").value; // in this example: 3

var Offset = PerRounded * Count; // in this example: 5,000.01

if ((Offset == TotalField) || (Offset == 0)) // in this example: TotalField = 5,000.00, Offset = 5,000.01

this.getField("WARNING_" + PerName).display = display.hidden

else

this.getField("WARNING_" + PerName).display = display.visible

}

I want the button to appear only when TotalField does not equal Offset. If the are equal, or if there is nothing entered it should be hidden. For some reason I am getting the opposite.

Thanks again!

try67
Community Expert
Community Expert
August 2, 2017

What's the code for the round function? Can you share the file, or post the full code, please?