Dynamically Rearranging DocType Sections with JavaScript in Frappe Client Scripts

In the Frappe framework, the sequence of sections within a DocType form is determined by the field order specified in the DocType fields definition. However, for enhanced user experience and customization, I aim to reorder these sections based on specific criteria programmatically. Specifically, I plan to leverage JavaScript code within the doctype[name].js file to rearrange the section dynamically breaks in alignment with my application’s logic. Join the discussion to explore techniques, share insights, and collaborate on optimizing DocType section ordering through client scripting.

1 Like

Interesting…

This is a cool idea, wonder if we can achieve this through modifying the idx value of the docfields…

Hi @dhiashalabi:

There is a feature called Doctype Layout, that could be useful.

Basically (and theorically) you can define more than one layout for each doctype, with different fields ordering. I think is actually you are looking for …

To be honest, I’ve never work with it, and seems is not updated, and maybe even is not working well in last releases. But probably you can explore how it works and how framework uses it internally …

Hope this helps.