How to make Child Items read-only base on a field value of the Parent Record?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Triggerz
    Member
    • May 2024
    • 58

    How to make Child Items read-only base on a field value of the Parent Record?

    Hi,

    How can I restrict the editing and adding of Child Items base on a field value of the Parent Record?
    The reason is that if the Parent Record status field value is updated to "Posted", I don't want any user to be able to modify or add child items anymore.

    Thanks in advance...
  • a.slyzhko
    Member
    • Oct 2023
    • 99

    #2
    Create API before save script for you child entity type.
    PHP Code:
    if (parentId && parentType) {
        $parentStatus = record\attribute(parentType, parentId, 'status');
        if ($parentStatus == 'Posted') {
            recordService\throwForbidden('Parent status is set to Posted. Adding new items and modifying existing is forbidden.')
        }
    } 
    

    Comment

    Working...