How can I expand/collapse a section from custom script/runtime?

Hi everyone, i’ve been searching everywhere for a reference code on how to expand/collapse a doctype section from runtime, couldn’t find any.

Can anyone tell me how I can expand/collapse a section from custom script?

execute below code in browser console when in sales order form
cur_frm.fields_dict[“contact_info”].collapse(0)
cur_frm.fields_dict[“contact_info”].collapse(1)

It works! Much thanks!