Hello I've created a ValidateDelte function on Sui...
# suitescript
f
Hello I've created a ValidateDelte function on Suitescript 1.0 unfortunately it's still firing regardless of the status and the role. Any reason why ?
Copy code
function validatedelete_removeline()
{
	//alert("In valididate delete")

  //Tell steve your issue on how it's firing on the administrator role aswell. 

  
  var userRole = nlapiGetContext().getRole();
  var soStatus = nlapiGetFieldValue('status');
  nlapiLogExecution('Debug','Debug Process',soStatus);
  nlapiLogExecution('Debug','User Role',userRole);
  /**
  * Here we put the Roles we want to lock the system on:
  * 1. AE Account Executive 1025
  * 2. AE Account Manager 1026
  * 3. AE Sales Manager 1038
  * 4. BT Account Executive 1082
  * 5. Director - Skytron 1061
  * 6. EMEA Sales Manager 1129
  *
  */
 if(soStatus == 'Pending Fulfillment'){
  if (_logValidation(userRole) == '1082' || _logValidation(userRole) == '1026' || _logValidation(userRole) == '1025' || _logValidation(userRole) == '1038' || _logValidation(userRole) == '1061' || _logValidation(userRole) == '1129' || _logValidation(userRole) == '1061' ){
  console.log('Please Start ????');
  nlapiLogExecution('Debug', 'Debug Process', 'Debug');
          alert("You are not able to remove this Line.");
  return false;
        
      }
      }

      function _logValidation(value)
      {
       if(value!='null' && value != null && value != '' && value != undefined && value != 'undefined' && value != 'NaN' && value != NaN)
       {
        return true;
       }
       else
       {
        return false;
       }
      }
s
the _logValidation(userRole) will return true, the your if will be executed like if(true==‘1082’…..)
try to validate your role in _logValidation function