Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Calculation in formcalc based on date

Avatar

Level 1

Hello,

I am a novice user of Adobe Livecycle but learning.  I am creating an expense voucher for employees to be reimbursed for mileage however I would like to create a if statement that says if the expense date is equal to or before June 30, 2012 then multiply the number of miles drived by a rate of $0.555 per mile and if the expense rate is equal to or after July 1, 2012 then multiply the number of miles by a rate of $0.600 per mile.  I have created specific fields labeled dteexpenseDate (field with user entered date),  decnumberMiles (number of miles driven) and decmileageRate (mileage rate). 

Currently, I have this code;

var currentDate = Date2Num(dteexpenseDate.rawValue = "2012-06-30")

var expenseDate = Date2Num(dteexpenseDate.rawValue, "YYYY-MM-DD")

var expenseTest = expenseDate - currentDate

     if(expenseTest<0) then

          sum(decnumberMiles*0.555)

     else

          sum(decnumberMiles*0.600)

     endif

I am using formcalc currently but would be open to using javascript. I am aware that this is not correct since I am getting errors but I haven't found anything on the internet to help me.  Any help would be greatly appreciated.

Thank you

Lindsay

1 Accepted Solution

Avatar

Correct answer by
Level 5

I am assuming you want to populate the last of the 3 fields (mileage rate)? If so, use the calculate event in formCalc with something like

var changeDate = Date2Num( "2012-07-01", "YYYY-MM-DD" )

var expenseDate = Date2Num( dteexpenseDate.rawValue, "YYYY-MM-DD" )

var expenseTest = expenseDate - changeDate

if ( expenseTest < 0 ) then

    $ = decnumberMiles * 0.555

else

    $ = decnumberMiles * 0.600

endif

FormCalc has its advantages (faster, better date handling, etc.) but its not as flexible as javascript along with the fact that there are not as many places on the web that can give you examples.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

I am assuming you want to populate the last of the 3 fields (mileage rate)? If so, use the calculate event in formCalc with something like

var changeDate = Date2Num( "2012-07-01", "YYYY-MM-DD" )

var expenseDate = Date2Num( dteexpenseDate.rawValue, "YYYY-MM-DD" )

var expenseTest = expenseDate - changeDate

if ( expenseTest < 0 ) then

    $ = decnumberMiles * 0.555

else

    $ = decnumberMiles * 0.600

endif

FormCalc has its advantages (faster, better date handling, etc.) but its not as flexible as javascript along with the fact that there are not as many places on the web that can give you examples.

Avatar

Level 1

That worked!  Thank you very much.

I would love to be more familiar with javascript, I guess I just have to jump in and figure it out.