Skip to main content
Alliosaaa
Inspiring
August 23, 2017
Question

InvalidSetError?

  • August 23, 2017
  • 1 reply
  • 1826 views

I am at a loss as to how to interpret this error. I'll try and lay this out as simply as possible.

I am working on a paperwork package for the selling of multiple vehicles. Some line items are divided evenly amongst the number of vehicles sold. If it is not possible to divide the item evenly, I have written a document-level function which calculates the offset in cents:

function remainderCatch(TotalField,PerField)

{

var PerRounded = round(PerField,2);

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

var Offset = PerRounded * Count;

var RemainderRaw = Offset - TotalField;

if (RemainderRaw == 0) {

   event.value = PerRounded

} else {

   event.value = (TotalField - ((Count-1) * PerField))

}

}

FYI:  The "round" function is a separate document-level function which rounds to the nearest decimal place of your choosing, the hundredths place in this example).

I have 5 fields which call this function, all under Vehicle #1 (so that only the first vehicle's numbers are adjusted). For this example, the line item I'm working with is called "DEPOSIT.0" (customer down-payment).

Calculation script under "DEPOSIT.0":

var DepositTotal = this.getField("TOTAL_DEPOSIT").value;

var DepositPer = this.getField("DEPOSIT_PER").value;

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

if (Count > 0)

event.value = remainderCatch(DepositTotal,DepositPer);

else event.value = ""

The calculation works just fine and I am seeing the correct numbers when it is executed. However, I am getting error messages in the console for each of the 5 fields which call this function, and all of them look like this:

InvalidSetError: Set not possible, invalid or unknown.

Event.value:7:Field DEPOSIT.0:Calculate

Can anyone see anything wrong with either code? I cannot figure this out.

Thank you so much in advance!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 23, 2017

If you're applying the value of the remainderCatch function to event.value, then that function actually needs to return a value...

Replace the "event.value = X;" commands in this function with "return X;".

Alliosaaa
AlliosaaaAuthor
Inspiring
August 23, 2017

What would I do without you!?

THANK YOU!