How to use length function in aras?server side method.

オフライン
//code to validatde item_number should not be more than 20 characters. Innovator inn=this.getInnovator(); Item itmid=this.getProperty("item_number"); //return this.getInnovator().newError("hello"); if(itmid.Length == 20) { return this.getInnovator().newError("Invalid Value!"); }  
Parents
  • Hi BK, The getProperty function returns a string, not an Item. You should update your code as shown below to declare the itmid variable to be a string.
    Innovator inn=this.getInnovator();
    string itmid=this.getProperty("item_number"); // <-- getProperty returns a string
    //return this.getInnovator().newError("hello");
    if(itmid.Length == 20)
    {
    return this.getInnovator().newError("Invalid Value!");
    }
    return this; // <-- Server-side methods always need to return an Item
    Chris ___________________________ Christopher Gillis Aras Labs Software Engineer
Reply
  • Hi BK, The getProperty function returns a string, not an Item. You should update your code as shown below to declare the itmid variable to be a string.
    Innovator inn=this.getInnovator();
    string itmid=this.getProperty("item_number"); // <-- getProperty returns a string
    //return this.getInnovator().newError("hello");
    if(itmid.Length == 20)
    {
    return this.getInnovator().newError("Invalid Value!");
    }
    return this; // <-- Server-side methods always need to return an Item
    Chris ___________________________ Christopher Gillis Aras Labs Software Engineer
Children
No Data