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

Brad Bowman
Kilo Patron
Kilo Patron

This is likely triggered on the var mgmtlvl or var locationNFC lines.  In prod, ensure that you have a field exactly named u_management_level (case- and space-sensitive) on the sys_user table, and that it has a value for the test case, and that you have a variable exactly named Work_location (case- and  space-sensitive) and that is has a value for the test case.  If the error is caused by one or both being blank, and that is a valid use case, then add a check to your script like:

if (!managerlvl.nil(())   
    var mgmtlvl = managerlvl.indexOf('L');
if (!location.nil()) 
    var locationNFC = location.indexOf('NFC');

Hi @Brad Bowman .

Thanks for the information. But both of those fields are filled with values .Even though this error is occuring 

Are you able to modify the script in prod then submit a new item to troubleshoot this?  You'll need to add log lines throughout the script, and maybe comment out a certain line at a time until you see what is causing the error.

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Check if these highlighted names are correct (especially capital N and Capital W)

AnuragTripathi_0-1700143242973.png

 

Try below and tell what you get in the logs

 

answer = checkMngr();
function checkMngr() {
  var managerlvl ='';
        var location  = '';
    var name = current.variables.Name;
    var usr = new GlideRecord('sys_user');
    usr.addQuery('sys_id', name);
    usr.query();
 
    if (usr.next()) 
{
gs.log('This was executed');
        managerlvl = usr.getDisplayValue('u_management_level').toString();
        location = current.variables.Work_location.toString();
}
gs.log('mgmtlvl  = '+mgmtlvl);
gs.log('location ='+location );
        var mgmtlvl = managerlvl.indexOf('L'); 
        var locationNFC = location.indexOf('NFC'); 
    if (((mgmtlvl >= 0) && (locationNFC >= 0)) || (locationNFC < 0))
{
      return 'yes';
    }
    return 'no';
}

 

-Anurag