Getting Wrapped Conversion Error:The undefined value has no properties error in workflow

Priyanka145
Tera Contributor

Hi All,

I am having a script in workflow as below

 

answer = checkMngr();
function checkMngr() {
    var name = current.variables.Name;
    var usr = new GlideRecord('sys_user');
    usr.addQuery('sys_id', name);
    usr.query();
 
    if (usr.next()) 
{
        var managerlvl = usr.getDisplayValue('u_management_level').toString();
        var location = current.variables.Work_location.toString();
}
        var mgmtlvl = managerlvl.indexOf('L'); 
        var locationNFC = location.indexOf('NFC'); 
    if (((mgmtlvl >= 0) && (locationNFC >= 0)) || (locationNFC < 0))
{
      return 'yes';
    }
    return 'no';
}
 
In prod  , we are facing an error with the same script , but in lower regions , it is working fine.
The error is :
Fault Descriptin: org.mozilla.javascript.WrappedException:Wrapped ConverstionError: The undefined value has no properties.
 
Why is this error occuring. Please guide me here what might be the issue.
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Priyanka145 

are you able to replicate this error in lower instance i.e. DEV and UAT?

If yes then it's an actual issue.

if not then it seems configuration or data issue.

Things to check

1) is the variable name correct? Name and Work_location

2) is the field u_management_level present on sys_user in production?

3) there is no need to GlideRecord as Name variable is already a reference one

4) the user you are having in Name variable has some value in it for the field u_management_level

try this once

answer = checkMngr();

function checkMngr() {

	var managerlvl = current.variables.Name.u_management_level.getDisplayValue();
	var location = current.variables.Work_location.toString();

	var mgmtlvl = managerlvl.indexOf('L'); 
	var locationNFC = location.indexOf('NFC'); 
	if ((mgmtlvl >= 0 && locationNFC >= 0) || locationNFC < 0)
	{
		return 'yes';
	}
	return 'no';
}

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

 

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