Dynamically sorting Timesheet Detail

Hi, just to know if there is an easy way to sorting dynamically rows in timesheet detail, here sorting by date (from_time), ascending.

I’m interested … ( I know there would be a “hard” way by just programatically taking the entries, deleting them and then inserting them in the right order)

Hi, indeed, there must be an hard way to prgramming but I’m sure that’s also an easy way … (hoping ;))

Hi, by custom server script, I think it’s possible. I will keep you posted if I find something

Hello,

You can set the idx using frappe.model.set_value. (e.g. frappe.model.set_value('Timesheet Detail', 'New Timesheet Detail 1', 'idx', 1);)

Once you are done modifying the idx, do cur_frm.refresh_field('<table_name>');

For this case, you may want to sort it first and iterate over the sorted timesheet detail, modifying the idx.

Regards,

Ivan

Thank you for your reply. I’m going to try.

Works great for me :wink: Thank you very much for your help