Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

InvalidSetError?

Explorer ,
Aug 23, 2017 Aug 23, 2017

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!

TOPICS
Acrobat SDK and JavaScript
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2017 Aug 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;".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2017 Aug 23, 2017
LATEST

What would I do without you!?

THANK YOU!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines