Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

order form with automatically calculation

Avatar

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
madona33
Level 1

15-02-2021

Hi everyone,

 

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

 

date and time field date condition date range

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
madona33
Level 1

22-02-2021

Dear radzmar,

 

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

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
madona33
Level 1

Likes

0 likes

Total Posts

6 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
madona33
Level 1

01-03-2021

 

 

 

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

23-02-2021

I would have to know the hierachy of your form to give a more suitable answer. Please provide some screenshots.

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

15-02-2021

Hi,

 

for date calculations you can use FormCalc, which is much easier than JavaScript. 

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

endif

$ = 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.