Refreshing the parent query after a specific action

When a Persistent Object (PO) gets saved/edited, Vidyano will automatically refresh the parent query of the PO is there is one. This is very handy and ensures that you never see ‘old’ data.

Sometimes however, you want more! What if I also want to refresh the parent query of the parent query of the PO? This is not something that is done automatically because, in 95% of the cases, this has no use and will not result in different data. Then there is the other 5%.

The solution

Let’s quickly head to the code to solve this problem. Very important is that this has to be solved at the client side. More information about why can be found in the background. I will show the code to solve this in the WPF client, but it can be done in the same way using the Web client.

  1. Add a ClientActions class to the client project. Make sure to name the class ‘YourPoName’ClientActions and make it inherit from the ClientActions class.
  2. Add the following code to the class
  3. public override bool OnAction(ExecuteActionArgs args)
               if (args.Action == "PersistentObject.Save")
                    if (args.PersistentObject.OwnerQuery != null)
                        var parent = args.PersistentObject.OwnerQuery.Parent;
                        if (parent != null && parent.Type != "ProgramUnit" && parent.OwnerQuery != null)
                    args.IsHandled = true;
                    return true;
                return base.OnAction(args);

So, what does this do. First of all, this code will be triggered when an action will be executed on the service. In this example, I override the Save behaviour. When the Save action is executed, I will first of all execute the Service request. This way, I’m actually saving the PO. When the request is done, I will lookup the parent query I need and make it search again. As last, I return true, to indicate that I don’t want any other default behaviour to be executed.

Off course, in a production environment, you want to do more type checking to make sure you have the correct query!


When Vidyano receives a query at the client side, then it actually receives the definition of the query. The actual results will be retrieved from the service when needed. This way, the service will not retrieve data that will never be shown on the screen. After receiving the actual data, the client will cache the results. The method shown above will perform a new search and will refresh the actual data.