Need Help with AJAX script

Annette Kitzmil
Tera Guru

Hello,

I am still learning the specifics for AJAX and need some help with the script below, specifically regarding how to script this so that the two red font lines below will either apply the reject_notes as the comments or the cancel_notes as the comments.  Probably pretty easy, but I am still learning and would appreciate the help please.

 

var EBSCMEUtilsAJAX = Class.create();
EBSCMEUtilsAJAX.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    retailRiskManagerApproval: function() {
        var cmeSysID = this.getParameter('sysparm_sysid');
        var statusCode = this.getParameter('sysparm_approval_state'); // approve, reject, cancel
        var comments = this.getParameter('sysparm_comments');
        var state;
        var approvalDate;
        //gs.info('App state ' + statusCode,'CME');
        var grCME = new GlideRecord('x_mtbr_ebs_cme_consumer_monitoring_reporting');
        grCME.get('sys_id', cmeSysID);
        //gs.info('grCME ' + grCME,'CME');
 
        grCME.reject_notes = comments; 
//grCME.cancel_notes = comments;
//grCME.work_notes = comments;
        grCME.u_choice_1 = statusCode;
        grCME.update();
        return grCME.sys_id;
    },
 
});
 
Thanks,
 
1 REPLY 1

harun_isakovic
Mega Guru

Something like this should work

 

if (statusCode == "reject") {
grCME.reject_notes = comments;
}
else if (statusCode == "cancel") {
grCME.cancel_notes = comments;
}