'Uncaught TypeError: Cannot set properties of null (setting 'g_parentDialog')' error on ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 04:57 AM
When an ATF has finished running, an error message of 'Uncaught TypeError: Cannot set properties of null (setting 'g_parentDialog')' occurs. I've looked for where 'g_parentDialog' is mentioned and is related to a UI Action. The code for that UI Action is:
function invokeAssessment() {
if (g_form.getReference('u_business_owner').active == 'true' && g_form.getReference('u_custodian').active == 'true') {
checkCurrentBia();
} else {
g_form.addErrorMessage("The BIA cannot be generated/continued until both Technical Application Owner and Divisional Application Owner role holders are active");
}
}
function checkCurrentBia(){
var businessApp = g_form.getUniqueValue;
//Access the glide ajax script include with the current sys id as a parameter
var gaAssessent = new GlideAjax('LBGBiaUtils');
gaAssessment.addParam('sysparm_name', 'currentAssessmentAjax');
gaAssessment.addParam('sysparm_bus_app',businessApp);
gaAssesment.getXML(generateAssessment);
function generateAssessment(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var data = answer.evalJSON(true);
if (data.wipBia == 'false') {
biaType();
} else {
gsftSubmit(null, g_form.getFormElement(), 'action_bia');
}
}
}
if (typeof window == 'undefined')
openCurrentBia();
function openCurrentBia() {
var util = new LBGBiaUtils();
var data =util.currentAssessment(current.getValue('sys_id'));
var urlArray = [];
urlArray.push(data.environmentUrl);
urlArray.push(data.biaInstance);
urlArray.push(data.biaMetricType);
urlArray.push(current.getValue('sys_id'));
var instanceUrl = gs.getMssage('lbg.bia.assessment.redirect.url' , urlArray);
action.setRedirectURL(instanceUrl);
}
function biaType(){
//generate pop up of UIage lbg_bia_dialog
var displayValue = g_form.getDisplayValue();
var biaDecisionPage = "lbg_bia_dialog";
var dialogWindow = new GlideModal(biaDecisionPage, false, "modal-md");
dialogWindow.setTitle(getMessage("Type of BIA"));
dialogWindow.setPreference("displayValue", displayValue);
//sysparm_id is the sys id of thecurrent business app
dialogWindow.setPreference("sysparm_id", g_form.getUniqueValue());
dialogWindow.render();
window.g_parentDialog = dialogWindow;
}
If somebody could let me know if there's anything wrong with the code or anything else that I need to look out for, that would be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2023 10:10 PM
In JavaScript, the majority of elements are objects, with the notable exceptions of null and undefined. When attempting to access an undefined variable, it invariably returns 'undefined,' and you cannot retrieve or modify any properties of an undefined object. This scenario triggers the "Uncaught TypeError: cannot set property of undefined." To mitigate this issue, it's crucial to ensure variable initialization, particularly in situations where initialization is missing. Furthermore, adhering to best practices, you should verify the values of variables for null or undefined before utilizing them. If you only need to ascertain whether a value exists, you can use an 'if' statement, and if you're uncertain about a variable's existence, use the 'typeof' operator to check it, like so:
if (value) {
// Perform an action
}
if (typeof some_variable !== "undefined" && some_variable !== null) {
// Manage the value
}