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