In a form orders i have a field calculation named “order_date” in which i writed:
now = new Date()
return now ;
Every time that i start orders the field “order_date” is autofilled with today_date, also if i am calling
a row in wich was stored a precedent date.
How have i to write an if statment so that
only if (order_date is empty)
today_date is returned ?
The question may be stupid but i am beginner.
Tanks in advance
Gianni Pinna
Dear Enrico,
You are always very prompt and kind.
Have You what Yoy wish.
Ciao.
Gianni Pinna
Dear Enrico,
I writed in calculation field order_date:
var now = new Date() ;
if (order_date == null)
{
return now ;
}
But i had 2 effects:
- Order_date which is second field in the form is displayed empty;
- First field which normally is autofilled is dispalyed empty too.
What error do i make?
Tanks in advance
Gianni Pinna
if (order_date == null)
{
order_date = new Date();
}
should work.
I am not able to understand what you are trying to do, but:
I think default values for global variables can be defined only if global are text or integer.. not datetime or media
If your problem is on a calculation field, be carefull to select it as a datetime
it the problem is on a method, the debugger can be of great help in finding problems with the application
Hope this help, ciao
Enrico,
tanks again. With a method I solved problem
var now = new Date() ;
if (order_date == null)
{
order_date = now
}
I have :
- associated method to on focus gain of order_date:
- made order_date : autoenter creationDateTime.
Now i am going to experiment with Your suggestions and making order_date as calculation field.
Tanks again
Ciao
Gianni Pinna
why do you need an method that checks for null?
if you have autoenter set on the order_date column it should always be filed in.
isn’t that the case?
Dear Jcompagner,
tanks for Your question, it may be that i have solved
the problem in a redundant way.
My intention was of :
- having order_date in new rows without rewriting order_date in old rows.
a) This was not possible with a calculation field [ var now = newDate() ;
return now;]
b) So i writed a metod as described, and it was right in order to my
intention. But the date was not autofilled in order_date, but,
although it was filled when i clicked on order_date in the form.
c) At this point i experimented with autoenter set in the order_date
column and i obtined my intention.
This is the way, but now, after Your question, i’ll try without method.
Best regards
Gianni Pinna