RetrieveXPathQuery in java action

I have a dataview that has many fields will be used for searching and when I tried to apply this search in the microflow I found that I will hit many times into database because I can not check (if this field is empty , then dont include it in the x-path constraint of retrieving the list from database) , thats leads me to separate the retrieving action so if I have 5 fields I have to hit into the database 5 times and that will affects the performance . And if I tried to retrieve the all data for this meta object first then filter them inside the microflow, I will face also a performace issue because It may returns millions records . so I think about the java action where I want to add xpath constraints one time according to the filled search fields by using this method of RetrieveXPathQuery , so how can I use this method to execute multible xpath query after checking the nullability of the fields to hit one time into database.
3 answers

You can use the following snippet in any java action. If you use user entered value, use the retrieveXPathQueryEscaped to escape any user input.

List<imendixobject> result = Core.retrieveXPathQuery(this.getContext(), "//ModuleName.TypeName[yourconstraint]");


Sorry Michel I dont understand that clearly: I want to apply this scenario of retrieve action of the microflow but in java action: Retrieve list from database of entity called EGateFrontEnd.Service with the follwing x-path constraint:

Entity called --->EGateFrontEnd.Service

[RequestStatus=$ServiceDetailsSearchObject/RequestStatus] [SourceType=$ServiceDetailsSearchObject/SourceType] [EGateFrontEnd.ServiceCard/EGateFrontEnd.Card/EGateFrontEnd.CardCardType= $ServiceDetailsSearchObject/EGateBackEnd.ServiceDetailsSearchObject_CardType]

where $ServiceDetailsSearchObject is just a temporary object of entity used only for searching.


I used this code

List<imendixobject> result = Core.retrieveXPathQuery(this.getContext(), "//EGateFrontEnd.Service[RequestStatus="+ServiceDetailsSearchParam.getRequestStatus().getCaption()+"]"); but it raised this error : Object 'EGateFrontEnd.Service' doesn't contain member 'Submitted', exception occured on mapping the following query: SELECT EGateFrontEnd.Service.* FROM EGateFrontEnd.Service WHERE EGateFrontEnd.Service.RequestStatus = EGateFrontEnd.Service.Submitted

while I just want to add the string value (ServiceDetailsSearchParam.getRequestStatus().getCaption()) but I dont know how?