You need to sign in to do that
Don't have an account?

Not allow to delete records from the Related list
I have two objects, Coat & Coat Line Item. These two objects having master-details relation ship
1) Coat is Master object
2) Coat Line Item is detail object.
Coat object is having one field "status". If status = "Approved" the records in the related list recors can not be deleted.
Let say "Sample" is record in "Coat object" and it is having 100 records in the "Coat Line Item" (Detail object) related list.
If the "Sample" record, Status="Approved". If any one deleting any record from the related list, does not allow to delete the record of the related list.
How to achieve this functionality? In how many ways we can achieve this functionality?
I hope by using triggers we can do. But am not sure.
Please give your ideas how to achieve this functionlity either by using coding & configuration (Both the ways)
Include NOT( ISNEW() ).
Like
AND( NOT(ISNEW()), ISPICKVAL( Status__c ,'Approved') , ISCHANGED( No_of_Employees__c ) ,true )
It should be fine now !!!
All Answers
Write trigger on the son object (in delete), checking if the status in the parent is Approved, than use function addError to the object. It will block the deletion
with out writing code is there any chance to do this functionality with Configuration???
I have two objects, Coat & Coat Line Item. These two objects having master-details relation ship
1) Coat is Master object
2) Coat Line Item is detail object.
Coat object is having one field "status". If status = "Approved" the records in the related list recors can not be deleted.
Let say "Sample" is record in "Coat object" and it is having 100 records in the "Coat Line Item" (Detail object) related list.
If the "Sample" record, Status="Approved". If any one deleting any record from the related list, does not allow to delete the record of the related list.
How to achieve this functionality? In how many ways we can achieve this functionality?
I hope by using triggers we can do. But am not sure.
Please give your ideas how to achieve this functionlity either by using coding & configuration (Both the ways)
one way is through trigger. Is there any way to achieve this functionality through Configuration with out using code????
Create rollup summary field in parent object and get count of child objects.
Create validation rule in parent object, if the status is approved and Rollup count is changed throw some message!!
Hope it works !!!
Kudos, I am glad.
It is working when am deleting records from the related list it is not allowing to delete records.
Now am trying to insert new record, I am getting the same validation rule error . It is not allowing me to create new records :(
The following validation rule i kept.
AND( ISPICKVAL( Status__c ,'Approved') , ISCHANGED( No_of_Employees__c ) ,true )
Not able to insert new records.
In that case,
You can check the new value and the prior value.If the roll up summary field value increases(i.e new record created) then dont process the logic and if it decreases(i.e record deleted ) then process the logic.
Include NOT( ISNEW() ).
Like
AND( NOT(ISNEW()), ISPICKVAL( Status__c ,'Approved') , ISCHANGED( No_of_Employees__c ) ,true )
It should be fine now !!!