The CreatorCon Call for Content is officially open! Get started here.

onload client script not working on custom table

raja_5
Tera Expert

Hi Experts,

I have a custom table where I have written an onLoad client script, but it is not working. I even tried just adding alert('message'), but it still doesn't work. Please suggest a solution.

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@raja_5 

share the script and client script config screenshot.

Also did you ensure UI type - ALL?

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

raja_5
Tera Expert
function onLoad() {
    alert("Client Script Loaded!");  /

    var CoordinatorSysId = g_form.getValue('u_coordinator');
    alert("u_site_ebs_coordinator: " + CoordinatorSysId);

    if (CoordinatorSysId) {
        var ga = new GlideAjax('CMSUtils');
        ga.addParam('sysparm_name', 'getTeam');
        ga.addParam('sysparm_Coordinator', CoordinatorSysId);
        ga.getXML(_handleResponse);
    }

    function _handleResponse(response) {
        var team = response.responseXML.documentElement.getAttribute("answer");
        alert("Received Team: " + team);

        if (team) {
            g_form.setValue('u_team', team);
        } else {
            g_form.clearValue('u_team');
        }
    }
}

Try the below

function onLoad() {
alert("Client Script Loaded!"); 

var CoordinatorSysId = g_form.getValue('u_coordinator');
alert("u_coordinator: " + CoordinatorSysId);

if (CoordinatorSysId) {
var ga = new GlideAjax('CMSUtils');
ga.addParam('sysparm_name', 'getTeam');
ga.addParam('sysparm_Coordinator', CoordinatorSysId);
ga.getXML(_handleResponse);
}

function _handleResponse(response) {
try {
var team = response.responseXML.documentElement.getAttribute("answer");
alert("Received Team: " + team);

if (team) {
g_form.setValue('u_team', team);
} else {
g_form.clearValue('u_team');
}
} catch (e) {
alert('Error processing response: ' + e.message);
}
}
}

Hi @Debasis Pati ,

 

Thank you for response!

 

its not calling client script 

alert is not being called

Hi @raja_5 ,

have you checked if your script include is marked for all accessible from all application scopes and as well as check in which scope it is?

DebasisPati_0-1739512269995.png

Mark the accessible from to all application scope and as well as share your script include script