how to automatically set the assignedUser same as the parents?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lj4353
    Senior Member
    • Nov 2023
    • 114

    how to automatically set the assignedUser same as the parents?

    I have created two entities, otherIncome and bonus, with a one-to-many relationship between them. I want to automatically set the assignedUser on the right side to be the same as the assignedUser of the corresponding otherIncome record when I create a new bonus record. How can I achieve this?​
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    Hey,

    Add this to the formula of the bonus entity under administration > Entity Manager > Bonus > Formula > Before Save Custom Script

    PHP Code:
    if (entity\isNew() && otherIncomeId && otherIncome.assignedUserId) {
        assignedUserId = otherIncome.assignedUserId
    }

    Make sure that the name otherIncome matche the name of the link field on bonus.
    Rabii
    Web Dev

    Comment

    Working...