Move value from Dialog box field to another doctype filed

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

Please help guys

You can use frappe dialog as following:

let d = new frappe.ui.Dialog({
title: 'Please Add the reason!',
fields: [
        label: 'Reason',
        fieldname: 'rejection_reason',
        fieldtype: 'Small Text',
        reqd: 1
primary_action_label: 'Save',
primary_action(values) {
    cur_frm.doc.rejection_reason = values['rejection_reason']


How to write those dialog field values to another doctype