Posts

Showing posts with the label Pre validate

PreValidate plug in example

Image
PreValidation plug in example: One of the most common interview question that never forgotten by any one and of course in Realtime this will rarely used. When we want to get no of child records when we are deleting the main/parent record then we can use PreValidation stage to get the count.   As some one thinks at very first time, why can’t we get the count in PreOperation stage. Because this will be in the same execution and we will not get the record count and by the stage it reaches to 20(PreOperation) all the child records gets deleted as per the relationship behavior.   So we need to register our plug in in PreValidaton. Below is the sample example to get the count of child records when we register the plug in in Delete message.   if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)             {        ...