Move Dialog box field value to doctype field after save

Hi guys

I need your help, please.

I found this code to make the user type the reason of rejection

frappe.ui.form.on(‘Purchase Order’, {
refresh(frm) {
if (frm.doc.workflow_state && cur_frm.doc.workflow_state == ‘Rejected’){
{‘fieldname’: ‘rejection_reason’, ‘fieldtype’: ‘Small Text’, ‘label’: ‘Reason’, ‘reqd’: 1}
show_alert(values, 5);
‘Reason for Rejection’,

How can I move the TEXT OF REJECTION REASON THAT USER WROTE IT INSIDE THE DIALOG BOX, to another field inside the doctype after clicking save?

Please help me with this guys

Thx in advance

Create a child doctype for purchase order rejection reasons and when capturing user input save it there.
Then customise the purchase order form and link the rejection reason field to the child doctype you created