Ampersand in where clause
When an ampersand (or single apostrophe) appears in the search criteria text that my workflow is querying against a layer's REST endpoint, an error occurs in my QueryTask due to the 'where' clause.
We're using Essentials 4.1.3.
If I type the search criteria text directly into the 'where' box at the REST endpoint of the map layer, then the query runs OK, so it's something in the workflow that's causing the problem.
This is from the log, showing how my search criteria have been interpreted. The ampersand character is: +&+
where=ICF_LEG+like+'%25DL+2518+PEACE+RIVER+EXC+PLS+18700+22630+31494+PGP41938+&+PGP44763%25'&outFields=*&f=json"}
</Event>
<Event Timestamp="2014-07-30T17:36:50.9268927-07:00" Level="DEBUG"><Message>ActivityStateRecord { InstanceId = 1af7770a-ab6d-4a0e-af98-b0ad8cb3e178, RecordNumber = 52, EventTime = 7/31/2014 12:36:50 AM, Activity { Name=Query Parcel Layer, ActivityId = 1.36, ActivityInstanceId = 14, TypeName=Geocortex.Workflow.Activities.QueryTask }, State = Faulted }</Message></Event>
<Event Timestamp="2014-07-30T17:36:50.9278693-07:00" Level="ERROR" Identity="PRRD\agssvr"><Message>Workflow 'SearchLegal' failed. Cause: Geocortex.Workflow.WorkflowException: Unhandled exception: 'One or more errors occurred.' in activity '1.36: Query Parcel Layer'. ---> System.AggregateException: One or more errors occurred. ---> ESRI.ArcGIS.Client.Tasks.ServiceException: Unable to complete operation.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Geocortex.Workflow.Activities.QueryTask.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
--- End of inner exception stack trace ---</Message></Event>
<Event Timestamp="2014-07-30T17:36:50.9278693-07:00" Level="ERROR" Identity="PRRD\agssvr"><Message>Exception has been thrown by the target of an invocation.
Workflow 'SearchLegal' failed
Unhandled exception: 'One or more errors occurred.' in activity '1.36: Query Parcel Layer'.
One or more errors occurred.
Unable to complete operation.</Message></Event>
<Event Timestamp="2014-07-30T17:36:50.9288459-07:00" Level="DEBUG" Identity="PRRD\agssvr"><Message>ServiceException: Unable to complete operation.
AggregateException: One or more errors occurred.
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Geocortex.Workflow.Activities.QueryTask.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
WorkflowException: Unhandled exception: 'One or more errors occurred.' in activity '1.36: Query Parcel Layer'.
RestException: Workflow 'SearchLegal' failed
at Geocortex.Essentials.Rest.Resources.RunWorkflowOperation.Run(String workflowString, String inputArgumentsString)
at Geocortex.Essentials.Rest.Resources.RunWorkflowOperation.RunWorkflow()
at Geocortex.Essentials.Rest.Resources.RunWorkflowOperation.WriteJsonInternal(Boolean pretty)
TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Geocortex.Essentials.Rest.EssentialsRestRequestDispatcher.ProcessRequestUnderContext()
-
Hi Mark,
I've also just run into this problem with my own workflows. I found another discussion https://support.geocortex.com/SupportForums/Thread.aspx?pageid=0&mid=2&ItemID=7&thread=45940 where they suggest an Assign Task to replace the single apersand with two ampersands. I have not tested it myself yet, but hopefully it works.
I've also noticed that the global search bar is not able to search with a single ampersand, but when you replace it with two ampersands, the global search works just fine. Do you think this problem will be fixed in the new release of HTML5 2.4?
0 -
Just tested it and it worked, the single apostrophe needs to be replaced by two single apostrophes.
Assign Task:
strLastName = strLastName.ToString().Replace("'","''")
0
Please sign in to leave a comment.
Comments
2 comments