Contact Person not auto-setting in Sales Order

Hi Everyone,

When I select a customer in the Sales Order, the Contact Person field is not auto-filled, even though the customer has a Primary Contact set.

I’m also using a custom script to set the payment terms from the customer, so I think that might be overriding the default behavior.

     frappe.db.get_value('Customer', frm.doc.customer, 'payment_terms', (r) => {
            if (r && r.payment_terms) {
                frm.set_value('payment_terms_template', r.payment_terms);

How can I make sure the Contact Person is auto-set based on the customer’s Primary Contact?