Preventing the Edit of an object

0
Hi all.   I am a bit stuck at the moment for which may have a very simple answer. But for me I can't figuer out how to do this. I know there is a default error handeling in entity associations. In ONE to MANY associations, we can set an on DELETE error message so that the user cant delete one object if data exists in the other. I was wondering how to get the same error message if some one tries to EDIT an Object. In my application I have one entity CATEGORIES and the other entity ITEMS. One Category is associated with many Items. I do not want a user to EDIT a Category when Items of that Category exists.. How to do this?   Please help Dylan
asked
1 answers
1

Dilan,

One way you could do this is to:

  • Create a microflow to open the Category edit page
  • In that microflow, retrieve Items associated with the passed in Category
  • If there are any Items, display an error message to the user
  • If there are not any Items, show the edit page to to the user

If you use this approach, you'll need to make sure you open the Category Edit page only with the microflow you just create.

Another approach:

  • Create a boolean attribute on the Category entity, lets call it Editable
  • Default value for Editable should be true
  • Create a microflow to be called as an After Commit event handler on the Item entity
  • In this microflow, retrieve the Category associated with the Item
  • If this Category has Editable = true, change it to Editable = false
  • Create another microflow to be called as an After Delete event hanlder on the Item entity
  • In the second microflow, retrieve the Category, then retrieve Items associated with that Category
  • If there are items, set Editable to false, if not, set Editable to true
  • Now you can use the Editable attribute on the Category entity to control Editability on your Category edit page
  • As an alternative, you can add Access Rules to the Category entity based on the Editable attribute

Hope that helps,

Mike

answered