Date field value is not populating by using setValue by using client scripts

Dinesh Kumar C
Tera Contributor

Hi Team,

I wrote a catalog client script and script include to change date format from YYYY-MM-dd to MM-dd-yyyy . Below are both catalog client script and script include.

Here the issue is script include returning the formatted date correctly but the setValue in catalog client script is not working and morover its recalling scripting include again and the values are keep changing. What wrong with below code?

OnChange Catalog client script :

var cdt = g_form.getValue('testing_date');
var ajax = new GlideAjax('test');
ajax.addParam('sysparm_name','addDateTimeAmount');
ajax.addParam('sysparm_fdt', cdt);
ajax.getXML(doSomething);

function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('testing_date',answer);

 

Script Include :


addDateTimeAmount: function(){
gs.info('dinesh');
var firstDT = this.getParameter('sysparm_fdt'); //First Date-Time Field

var day = new GlideDate();
day.setValue(firstDT);
var formattedDate = day.getByFormat("MM-dd-yyyy");
gs.info('dineshtestresult '+formattedDate );
return formattedDate ;

}

 

I can able to see the info logs that the format is changing but issue is after selecting the date the script is processing multiple times and date is keep on changing randomly. This is weird 😞 .

 

You can find in the below image that selected date is different and alerted date value is different. 

find_real_file.png

1 REPLY 1

Shashi Bhushan
Kilo Guru