I would need help to create a date and total calculation in an order form, I am really new in this field, I would appreciate any help, thanks
Basically, we are a small event organisation, we offer some products to our clients, the order form works brilliantly as it's but because we receive often orders very late,we would like to add a script to do the following:
1- There is a field called "event start date " in DD/MM/YYYY format, so If the order has been filled in within 20 days prior to the event start date (event start date <= 20), then 20% surcharge will be added to the total (there is a field called "surcharge" before the total and will be added to the total charges) , if the event start date > 20 days then the form should work as it is
2- In case that the difference is <=20 then a notification should appear to notify the client that 20% surcharge will be added to the total due to the late order.
3- If possible, we don't prefer to add a field called " today's date" (we need only "event start date" ), so the script should compare the actual date with the event start date without entering the actual date.
4 - To stop the script from running , in case we receive and open the form within the 20 days (in case clients send it before the 20 days deadline), is it possible to lock the form after the client saved it , so the form doesn't pick up today's date and recalculate the total if we open it later within the 20 days before the event.
Many thanks in advanced
I am really sorry, I accepted the answer by mistake, please see below
Many thanks for your reply and sorry for the delay in responding. I tried the code provided but it doesn't work.Basically, if the Date2-Date1<20 then surcharge (field called sur) should be 20% of the total (I have a field for total, called Total ). Both dates fields are in form DD/MM/YYY. Any suggestions please? Many thanks
I would have to know the hierachy of your form to give a more suitable answer. Please provide some screenshots.
The surcharge can be calculated in this way for example:
var nSurcharge = 0
if (Date2Num(EventStartDateField.formattedValue, "DD/MM/YYYY") - Date() le 20) then
nSurcharge = 20
$ = nSurcharge
To protect a form, you can either lock the uppermost element in your form or every single field.
There are plenty of examples in this forum available about this.