On Jam.py v7 - Tried setting a Read Only value through Client Module but doesn't work

28 views
Skip to first unread message

SS P

unread,
Jun 17, 2025, 2:23:21 AM6/17/25
to Jam.py Users Mailing List
Database sqlite, Jam.py Version 7

I am trying to set the Financial Year Start and End Dates automatically when a new FY is created.
On a working v5 project, in the Client Module I could set a "Read Only" field through the code. However i am not able to do that in v7. (The same code doesn't work in the new v7 project)
In the code, financial_year ,  start_date and  end_date are Read Only fields.

function on_edit_form_created(item) {
        var curr_yr = new Date().getFullYear();
        var nxt_yr = curr_yr+1;
        item.financial_year.value = curr_yr.toString() + "-" + nxt_yr.toString();
        item.start_date.value = new Date(curr_yr, 3,1);
        item.end_date.value = new Date(nxt_yr, 2, 31, 23,59,59);
}

This worked fine on v5 and I could set the fields which were set as Read Only while the Item Field was created in the builder. On v7 the fields don't get committed/saved.
Am I missing something?

Dean D. Babic

unread,
Jun 17, 2025, 3:01:08 AM6/17/25
to Jam.py Users Mailing List

Dean D. Babic

unread,
Jun 17, 2025, 3:21:35 AM6/17/25
to Jam.py Users Mailing List
Pls have a look in here:
Categories table, "Income or expense" field. 

function on_edit_form_created(item) {
    if (item.is_new()) {
        item.income_or_expense.read_only = false;
    }   else {
        item.income_or_expense.read_only = true;
    }     
}
In the code you are not setting read_only at all....

SS P

unread,
Jun 17, 2025, 4:34:38 AM6/17/25
to Jam.py Users Mailing List
Thank you, Dean! Solves my problem!
Reply all
Reply to author
Forward
0 new messages