The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

There is a JavaScript error in your browser console

Nandana
Tera Contributor

[SCRIPT:EXEC] Error while running Client Script "On Load": TypeError: Cannot set property '_visible' of undefined

Onload client script written on table form is not working in Service Portal after upgrade.

function onLoad() {

if(g_form.isNewRecord())
{
g_form.setSectionDisplay('activity',false);
}

}

1 ACCEPTED SOLUTION

I installed Patch 1 of Orlando release (orlando-12-11-2019__patch1-02-19-2020_02-26-2020_1720), which included PRB1382041, which I described above. I can confirm that the error message will be not more displayed.

The fragment of the code of initGlideForm of spModel, which I described above, is fixed now and it looks like the following

g_form.$private.events.on('propertyChange', function(type, fieldName, propertyName, propertyValue) {
	if (propertyName == "mandatory")
		$scope.mandatory = c.populateMandatory(flatFields);
	if (propertyName == 'messages') {
		if (propertyValue && propertyValue.length)
			spAriaUtil.sendLiveMessage(propertyValue);
	}
	if (isCatalogItem && type === "SECTION" && propertyName === "visible") {
		var section = _getSection(fieldName);
		if (section) {
			var mandatoryFields = $scope.mandatory.filter(function(field) {
				return field._parent === section.id;
			});
			if (mandatoryFields.length) {
				section.visible = true;
				return;
			}
			var sectionContainer = $scope.formModel._fields[section.id];
			if (sectionContainer)
				sectionContainer._visible = propertyValue;
		}
	}
});

The new code fragment with sectionContainer makes the code safe.

View solution in original post

9 REPLIES 9

Allen Andreas
Tera Patron
Tera Patron

Hi,

You're not able to use that type of setSectionDisplay in regard to the Portal.

Please refer to this link for an alternative method.

https://community.servicenow.com/community?id=community_question&sys_id=b4375e91dbf9bf44e0e80b55ca96...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
I invite you to visit my ServiceNow focused YouTube channel: Allenovation!

Miguel Donayre
ServiceNow Employee
ServiceNow Employee

Set the UI type value on the client script to desktop. Some forced views can't be done on the portal and only work on the back end. 

find_real_file.png

Nandana
Tera Contributor

Changed UI type to Desktop removed error and even the section was not visible on the Portal. Thanks Miguel!!

AWESOME! I am glad it worked. Can you mark my solution as "correct"? That way other users that have the same issue can see that it work and could help them!

Thanks,

Miguel