Skip to main content
Question
Asked a question 2 years ago

I have two entities If I inactivate parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.

Where am I?

In Semarchy Community you can ask and answer questions and share your experience with others!

Fathia JamaSemarchy Team
Sr. Customer Success Consultant at Semarchy

If you have an attribute in the parent entity called Inactive and based on that value you want to set an attribute in the child entity, you can achieve this use case using an enricher. 

First you will need to create the enricher on the child entity. I have provided screenshots of my test example, I have a Department( parent) Employee (child) relationship. In the Employee entity have created this enricher 

I have two entities If I inactivate  parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.

My SemQL expression is as follows 

CASE when Department.Inactive ='Y' then 'Y' when Department.Inactive ='N' then 'N' else  Inactive  end

Once you have your expression created. I would recommend using the enricher in your form and not in a batch. Running the enricher on the form directly ensures you will get the most current value in the Department entity. 

In your stepper, you will want to enable under Form enrichers > On Form Open 

I have two entities If I inactivate  parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.

Now you can save and deploy your model. 

In your UI, you can see now when I created a record in Department with an inactive value of Y then in the employee entity the value is automatically filled with the Y value also

I have two entities If I inactivate  parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.
I have two entities If I inactivate  parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.

If you also want to set the Inactive attribute in the child entity to read only, so that it is not editable at all, you can set that in your child entity form under Properties > General 

I have two entities If I inactivate  parent record, Corresponding child record should also get inactivated. For Ex:- I have Location table and corresponding HCP location . If I make location as inactive corresponding HCP Location should also get inactivated. What could be the approach to achieve this.