Hi all,
question from here:
I initially misunderstood the question so answered with this:
Add this into your form (jam.py v7):
function on_before_post(item) {
if (item.is_new()) {
let copy = item.copy();
copy.open();
if (copy.rec_count ===0) {
item.tach_in.value = 1;
} else {
item.tach_in.value = item.tach_out.value;
}
}
}
However, I think the user would like to see the last entry on the form when creating a new record.
So, I think we need the last value of the tach_out :
function on_edit_form_shown(item) {
if (item.is_new()) {
let copy = item.copy();
copy.open();
if (copy.rec_count === 0) {
item.tach_in.value = 1 ;
} else {
let copy = task.flight.copy();
copy.open({fields: ['tach_out']});
copy.last();
item.tach_in.value = copy.tach_out.value;
}
}
if (item.tach_out.value) {
item.total.value = item.tach_out.value - item.tach_in.value;
} else {
item.total.value = 0;
}
}
When the user creates a new record, the tach_in will be automatically populated.
I think this is similar to this questions: