Updating a custom field value

sanvi
Tera Expert

Hi,

 

I have a requirement where 'Assigned User' is a field on a custom table.

Whenever the assigned value changes 'TCL' is a string field and the count should be updated with the count of all records that are assigned to 'Assigned User'.

Have configured the below client script and script include. But it isnt working as expected. Can someone correct me.

 

Client script - onChange Client script

var reqFr = new GlideAjax('TestScript');
reqFr.addParam('sysparm_name', 'orderCount');
reqFr.addParam('sysparm_reqfor', newValue);
reqFr.addParam('sysparm_state', g_form.getValue('state'));
reqFr.getXML(getOrderValue);

function getOrderValue(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('TCL', answer);
}
}

 

Script Include :

var TestScript = Class.create();
TestScript.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    orderCount: function() {
        var usr = this.getParameter('sysparm_reqfor');
        var progress = this.getParameter('sysparm_state');
        var count = 0;
        var gr = new GlideRecord('customtable');
        gr.addQuery('assigned', usr);
        gr.addEncodedQuery('stateNOT IN-12,-19');
        gr.query();
        while (gr.next()) {
            var cnt  = count ++;
 
        }
        return cnt;
    }
 
});
 
 
Even though they are total of 5 records with the user, the above script is showing only 3
0 REPLIES 0