OnLoad not running part of the script
search cancel

OnLoad not running part of the script

book

Article ID: 106294

calendar_today

Updated On:

Products

CA Service Catalog

Issue/Introduction

A script on first load indicates that a function is not found (see below error), but on refresh it executes successfully

Environment

CA Service Catalog 17.x

Resolution

This may be a timing issue.

While it may not always solve the problem this can sometimes be solved by setting the scope and then switching to that scope.

Couple of examples:

Example #1

onLoadFormCommon : function(){ 
departmentcostcenterhidden = false; 
var scope = ca_fd.fdScope; 
var formid = ca_fd.formId; 
setTimeout( function(){ 
ca_fd.switchFdScope(scope,formid); 
ca_fd.js.requestedForType(); 
ca_fd.js.chargeAreaType(); 
},1000); 
}, 

Example #2

var scope = ca_fd.fdScope;
var id = ca_fd.formId;
ca_reportQuery('get-user-supervisor', { 'userid': for_user }, function (rows) { ca_fd.switchFdScope(scope,id);ca_fd.js.setSupervisorFromQuery(rows, ca_fd.formId) }, null);

Another possible solution is to add a timeout to the JS code - How to Set a Timer in JavaScript

Additional Information