The CreatorCon Call for Content is officially open! Get started here.

How to add Rejection reason ( on UI pop up ) to the Comments field and set Approval State to Reject?

Virendra K
Kilo Sage

Hi All,

 

Per requirement, When bulk/uniform rejection of approval is there then I need to pop a window with a field call " Rejection Reason" then need to capture "Rejection Reason" to the Comments field of Approval and also set Approval State to Reject.

I know I need to create UI Page to pop up a window, but how I could capture the Rejection reason fields values to the approval Comments field?

 

Thank you.

 

Regards,

Virendra

2 REPLIES 2

PVJShareKnowled
Tera Guru

I have worked on similar requirement to populate onhold reason and copying the same to comments also. You can refer this and make modifications. Below code will give a pop up window and fields like onhold reason and comments.

function onClick(g_form) {

    var holdReason = [{
        type: 'choice',
        name: 'hold_reason',
        label: getMessage('On-hold reason'),
        mandatory: true,
        choices: [{
                displayValue: 'Awaiting Caller',
                value: '1'
            },
            {
                displayValue: 'Awaiting Change',
                value: '5'
            },
            {
                displayValue: 'Awaiting Problem',
                value: '3'
            },
            {
                displayValue: 'Awaiting Vendor',
                value: '4'
            },
            {
                displayValue: 'Awaiting Approval',
                value: '6'
            }
        ]
    }];

    var holdComment1 = [{
        type: 'textarea',
        name: 'holdComment1',
        label: getMessage('Additional Comments'),
        mandatory: true
    }];

    g_modal.showFields({
        title: "Please provide onhold reason",
        fields: holdReason,
        size: 'md',
    }).then(function(selReason) {

        if (selReason.updatedFields[0].value == '1') {
            g_modal.showFields({
                title: "Provide details on the onhold reason",
                fields: holdComment1,
                size: 'md'
            }).then(function(newHoldComment) {
                g_form.setValue('incident_state', 3);
                g_form.setValue('state', 3);
                g_form.setValue('hold_reason', selReason.updatedFields[0].value);
                g_form.setValue('comments', newHoldComment.updatedFields[0].value);
                if (g_form.getValue('hold_reason') == 1 && g_form.getValue('caller_id') == g_form.getValue('assigned_to')) {
                    g_form.addErrorMessage('The Caller and Assignee cannot be same person for the on hold reason "Awaiting Caller"');
                    g_form.setMandatory('hold_reason', false);
                    g_form.setValue('hold_reason', '');
                    g_form.setValue('incident_state', 2);
                    g_form.setValue('state', 2);
                    //g_form.addInfoMessage('inside if condition');
                    return false;
                }
                g_form.save();
            });
           } else {
            g_form.setValue('incident_state', 3);
            g_form.setValue('state', 3);
            g_form.setValue('hold_reason', selReason.updatedFields[0].value);
            g_form.setValue('comment',newHoldComment.updatedFields[0].value);
            g_form.save();
            //gs.addInfoMessage.getMessage('Incident ' + current.number + ' is "On-Hold".');
        }
    });
}

 

If this input helped you, please give a thumbs up. It encourages me to answer more questions and support our community.

Regards,


Priyanka Jeganathan

Thanks for the input @PVJShareKnowled 

Where did you write this coding part ? UI Action ?