Hi @Ankur Bawiskar ,
No alerts are populating.

Here is the scripts

 

Client Script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var ajax = new GlideAjax('Dtetimeutils');
    ajax.addParam('sysparm_name', 'getDateValue');
    ajax.addParam('sysparm_inc', newValue);
    ajax.getXML(getDate);
    function getDate(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert('date is' + userObject.u_show_start_date);
        g_form.setValue('u_show_start_date', answer);
        alert('answer');
    }
}
Script Include (client callable)
var Dtetimeutils = Class.create();
Dtetimeutils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
 getDateValue: function() {
        var sysId = this.getParameter('sysparm_sysid');
        var rec = new GlideRecord('u_show_impacted');
        if (rec.get(sysId)) {
            return rec.u_start_date.getDisplayValue();
        }
    },
    type: 'Dtetimeutils'
});

@e__rajesh_badam 

did you add gs.info() in script include and see if the function was called?

script include and client script are in same scope?

I believe I already answered your question, please debug further and enhance if any changes required

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thank you so much for your quick assistance and I achieved it with your initial code itself by adding date format conditions (bold and Underlined).

 

Here is the Script for reference

 

Client Script:

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var userObject = g_form.getReference('u_show_impacted', updateShowStartDate);


    function updateShowStartDate(userObject) {

        // g_form.setValue('u_show_start_date', userObject.getValue('u_start_date'));

        var startDate = new Date(userObject.getValue('u_start_date'));
        var show_start_date = formatDate(startDate, g_user_date_format);
        g_form.setValue('u_show_start_date', show_start_date);
    }
}

View solution in original post

J Siva
Kilo Patron

Hi @e__rajesh_badam 

Try below script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var userObject= g_form.getReference("u_show_impacted", doAlert);


    function doAlert(userObject) {
        
        g_form.setValue('u_show_start_date', userObject.getValue('u_start_date')); //Make sure to use the correct field name
        
    }
}

NOTE: While setting the date value you are not picking the correct field name. Check that. Also please share the snap of your onchange client script configuration.

As per my script, you onchange client script should be configured on "Show impacted" field and UI type should be "All"

 

Regards ,

Siva

View solution in original post

Thank you @J Siva i.e., Correct and it is populating date now but format taking is in opp format when loading

Table data:

e__rajesh_badam_0-1743609220233.png

Incident reflection:

e__rajesh_badam_1-1743609266268.png