onBeforeUpdate - 'Not a single item' error

I have onBeforeAdd and onBeforeDelete methods on an ItemType to change a property depending on the status of that property on other instances of that ItemType. Those work fine. But when I tried to add an onBeforeUpdate method to detect when another property was changed, the 'Not a single item' error shows up. I'm also not able to use the apply() method on any item that is changed on the update method. I just need to know how to make a change to the item stick when using an Update server method.

Parents
  • Hello,

    The onBeforeUpdate event triggers before the standard update functionality performs the apply() for you automatically. To update the property, all you need to do is set the property on the item and return that item from the onBeforeUpdate like so.

    this.setProperty("item_number", "New Item Number");

    return this;

    Chris

    Christopher GIllis

    Aras Labs Software Engineer

  • Thank you for your response. I have conditional statements to maybe change 'this', but I also need to be able to change every other ItemType of this type in the database. So I loop through them and set their properties depending on the value of 'this'. This works fine with onBeforeAdd and OnBeforeDelete, but onBeforeUpdate either freezes Aras or gives the 'Not a single item' error. I guess I need to know how to change other items in a loop using onBeforeUpdate.

Reply
  • Thank you for your response. I have conditional statements to maybe change 'this', but I also need to be able to change every other ItemType of this type in the database. So I loop through them and set their properties depending on the value of 'this'. This works fine with onBeforeAdd and OnBeforeDelete, but onBeforeUpdate either freezes Aras or gives the 'Not a single item' error. I guess I need to know how to change other items in a loop using onBeforeUpdate.

Children