Hello,
So, the task is to pop up a modal with a list coming from a table that was created to hold the declination reasons as shown below. I was able to get the reasons from the table to display in the drop down and behind the drop down is a comments field also. What I am trying to accomplish now is the following:
1) I want the declination reason to NOT log to the activity log as a sys id, but the actually verbiage as shown below.
2) I want any comments entered by the user to also log to the activity log.
3) Lastly, I need to make sure that when the declination reason is captured it is updating the main record on the table it is referenced from (our main record table). This table has a reference field to the new table "declination reasons" on it.
My code is below, can someone take a look and tell me what I am missing here please?

Client Script:
function onClick(g_form) {
g_modal.showFields({
title: "Enter Declination Reason",
fields: [
{
type: 'reference',
name: 'declination_reason',
label: getMessage('Declination Reason'),
mandatory: true,
reference: 'x_mtbr_ebs_rdep_delincation_reasons',//Table being referenced
referringTable: 'x_mtbr_ebs_rdep_retail_deposit_exception_pricing',//Table referenced from
referringRecordId: g_form.getUniqueValue(), //Sys_Id of the value being called in the ui action form
value: g_form.getValue('declination_reason'),
displayValue: g_form.getUniqueValue('declination_reason'),
},
{
type: 'textarea',
name: 'work_notes',
label: getMessage('Comments'),
mandatory: false
}],
size: 'lg'
}).then(function(fieldValues) {
//call AJAX script
alert(fieldValues.updatedFields[0].value);
alert(fieldValues.updatedFields[1].value);
var ga = new GlideAjax('x_mtbr_ebs_rdep.RDEPUtilsAJAX');
ga.addParam('sysparm_name', 'rdepDeclineUpdate');
//ga.addParam('sysparm_state', 'bm_declined'); // rejected
ga.addParam('sysparm_comments', fieldValues.updatedFields[0].value);
ga.addParam('sysparm_reasonSysId',fieldValues.updatedFields[1].value);
ga.addParam('sysparm_sysid', g_form.getUniqueValue());
//alert(fieldValues.updatedFields[0].value);
ga.getXML(reload);
});
}
function reload() {
g_form.reload();
}
AJAX Script:
rdepDeclineUpdate: function() {
// gs.info('RDEPUtilsAJAX');
var sysId = this.getParameter('sysparm_sysid');
var reasonSysId = this.getParameter('sysparm_reasonSysId'); // value[1]
var comments = this.getParameter('sysparm_comments'); // used for Approval notes; value[0]
var grRDEP = new GlideRecord('x_mtbr_ebs_rdep_retail_deposit_exception_pricing');
grRDEP.get('sys_id', sysId);
var branch_num = grRDEP.opened_by.cost_center.account_number.toString();
var statusCode = grRDEP.getValue('status');
if (branch_num == '1043') {
if (statusCode == 'submitted' || statusCode == 'resubmitted') {
grRDEP.status = 'pt_declined';
}
} else {
if (statusCode == 'submitted' || statusCode == 'resubmitted') {
grRDEP.status = 'bm_declined';
} else if (statusCode == 'bm_approved') {
grRDEP.status = 'pt_declined';
}
}
grRDEP.comments = comments;
grRDEP.reasonSysId = reasonSysId;
grRDEP.update();
//return grRDEP.sys_id;
},
Thank you for any assistance in narrowing down what I am missing here.