These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Same topic still not help

goslinc
Registered: Sep 25 2007
Posts: 114

I am still unable to get past this, something is not working. If BorrowStatus is answered 1, then my fee is to be calculated at AIssue * 0.002, if this amount ends up being greater than 1000 the fee should be set to $1,000. If this amount ends up being less than $100 the feel should be set to $100, if neither of those apply, the fee should just remain at the AIssue * 0.0002

----- dataroot.Receipt.Fee::calculate: - (JavaScript, client) --------------------------------------

var dataroot.Receipt.Fee = 0 // clear the fee value
if (dataroot.P1.SReport.BorrowStatus == 1) then
dataroot.Receipt.Fee = dataroot.P1.SReport.AIssue.rawValue * 0.002;
if (dataroot.Receipt.Fee > 1000) then
dataroot.Receipt.Fee = 1000 // maximum value
endif // maximum value
// test for below minimum fee
if (dataroot.Receipt.Fee.< 100) then
dataroot.Receipt.Fee = 100 // minimum value
endif // minimum value
endif // Qstn1
$.rawValue = dataroot.Receipt.Fee //set the field value

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The first thing I see is, that you use a FormCalc script but set the calculate:event to run with JavaScript!

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

goslinc
Registered: Sep 25 2007
Posts: 114
Can you show me how saying the same thing in javascript would look?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Why don't you just set the calculate:event to FormCalc in the script editor?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

goslinc
Registered: Sep 25 2007
Posts: 114
Because I get a script failed message, context is xfa.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Without knowing your form structure I found 2 errors in the script.

1. This one is nonsense, because a variable name doesn't contain dots!
To clear the field "Fee" remove the "var" expression.
var dataroot.Receipt.Fee = 0 // clear the fee value

2. The dot after Fee is to much, remove it!
if (dataroot.Receipt.Fee.< 100) thenCorrected script:
dataroot.Receipt.Fee = nullif (dataroot.P1.SReport.BorrowStatus == 1) thendataroot.Receipt.Fee = dataroot.P1.SReport.AIssue.rawValue * 0.002;if (dataroot.Receipt.Fee > 1000) thendataroot.Receipt.Fee = 1000 // maximum valueendif // maximum value// test for below minimum feeif (dataroot.Receipt.Fee < 100)  thendataroot.Receipt.Fee = 100  // minimum valueendif // minimum valueendif // Qstn1$.rawValue = dataroot.Receipt.Fee //set the field value

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

goslinc
Registered: Sep 25 2007
Posts: 114
So what you have provided is the formcalc version and it appears to work. Thank you. I was first given an example by gkaiseril out here on 2-11-2010 and it was not working for me.

I still would like to know how this same calculation would occur in javascript if you would be so kind?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Well, most of script EXAMPLES here or in other comunities need to be changed to be compatible to your own form.
Nobody will have a form that is exactly designed as yours, so you can't expect a script will work instantly on yours.

I made a redesign of the FormCalc script, it should match your needs.
var FeeValue = nullvar AIssueValue = dataroot.P1.SReport.AIssuevar BorrowStatusValue = dataroot.P1.SReport.BorrowStatus if (BorrowStatusValue == "1") thenFeeValue = AIssueValue * 0.002if (FeeValue > 1000) thenFeeValue = 1000 ; maximum valueelseif (FeeValue < 100)  thenFeeValue = 100  // minimum valueendifendif$ = FeeValue

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi goslinc,

radzmar is correct that many times scripts you find will not work exactly as you want them to, and also may contain some errors. No one here is paid to answer questions and the code provided is written to provide guidance to help you get your task done, not a form of private professional consulting or finished, rock solid code.

You must spend a lot of your own time as well to get the exact results you need. Here is an article on why scripts you copy and paste from other sources may or may not work for your exact situation-
http://www.acrobatusers.com/blogs/thomp/copying-and-pasting-code

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
goslinc
Registered: Sep 25 2007
Posts: 114
I appreciate all the information. Sounds like I may have offended and sure did not mean to, was only providing as much information as I could in reply to the nonsense remarks about the existing code I had in place.

I am very thankful for these forums and those who assist us. I don't make a habit of cutting and pasting scripts provided out here. I do know they must be changed to reflect our specifics and I spend as much time as possible reading the articles and watching the tutorials. Sometimes, you just need the experience of others to push you past the difficult spots.

Thanks again