Unable to query objects using createXPathQuery with variable

0
Hello, I have a requirement to generate dynamic X Path based on input object. So i have written a Java Action that takes input object (__SearchCriteria) as parameter. My code looks like below (For Simplicity, i have hard coded the values for now)     public java.util.List<IMendixObject> executeAction() throws Exception     {         this.SearchCriteria = __SearchCriteria == null ? null : partvolumeplanning.proxies.ProgramSearchCriteria.initialize(getContext(), __SearchCriteria);         // BEGIN USER CODE          String remoteTypeXPathStr    = "//AdientPartVolumePlanning.AdientProgram[Name=$SearchCriteria/Name]";         XPathQuery xPathQuery = Core.createXPathQuery(remoteTypeXPathStr);         xPathQuery.setVariable("SearchCriteria", __SearchCriteria);         return xPathQuery.execute(getContext());       // END USER CODE }         It fails at following  Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.connectionbus.ConnectionBusRuntimeException: An exception has occurred for the following request(s):      InternalXPathTextGetRequest (depth = 0): //AdientPartVolumePlanning.AdientProgram[Name=$SearchCriteria/Name]     at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.scala:84)   I Tried following as well, // BEGIN USER CODE String remoteTypeXPathStr    = "//AdientPartVolumePlanning.AdientProgram[Name=$namevar]"; XPathQuery xPathQuery = Core.createXPathQuery(remoteTypeXPathStr); xPathQuery.setVariable("namevar", “Name1”); return xPathQuery.execute(getContext()); // END USER CODE and it fails with InternalXPathTextGetRequest (depth = 0): //AdientPartVolumePlanning.AdientProgram[Name=$namevar]   I would really appreciate any help here. Thanks, Sachin
asked
0 answers