Check for duplicate serial numbers

I'm trying to check for duplicate serial numbers on add and update, the problem is that a serial number can be blank. How do I check for only serial numbers that have values. Innovator inn=this.getInnovator(); // Block User if Delivered Component already exist string DeliveredCompSN = this.getProperty("item_number"); Item check = this.newItem("MIN_Delivered_Component","get"); check.setProperty("item_number",DeliveredCompSN); check = check.apply(); if (check.getItemCount()>1){ return inn.newError("Serial Number already exists in Delivered Componets"); } return this;
Parents
  • Hello, You should be able to do this with an if statement like if(String.IsNullOrEmpty(DeliveredCompSN){return this;} right after the 3rd line of your sample code.  This way if the serial number is blank, the server call to get any duplicate Components isn't even made. Chris
    Christopher Gillis Aras Labs Software Engineer
Reply
  • Hello, You should be able to do this with an if statement like if(String.IsNullOrEmpty(DeliveredCompSN){return this;} right after the 3rd line of your sample code.  This way if the serial number is blank, the server call to get any duplicate Components isn't even made. Chris
    Christopher Gillis Aras Labs Software Engineer
Children
No Data