Server workflow unexpected error in Format Date activity
I pass a value from a form's DateTimePicker to a server workflow.
In order to match up with SQL smalldatetime data type, I use the Format Date activity as such
- Date input = =$getWorkflowInputs1.inputs.attributes["InspectionDate"]
- Format input = YYYY-MM-DD HH:mm:ss
On the server, I am logging that input and so I know that it is successfully passing the DateTimePicker.value.value as a Unix epoch (value in ms bolded below) :
{
"start": "2023-06-28T18:47:09.042822Z",
"end": "2023-06-28T18:47:09.0706906Z",
"artifacts": [
{
"$type": "JobResult",
"outputs": {},
"tag": "4f4366e88b164c13b5a8752023e59bb1"
},
{
"$type": "JobQuit",
"kind": "Run"
}
],
"traces": [
"VertiGIS.Workflow.Server Information: 0 : WORKFLOW INPUTS: - 1687978020000",
"Information: 0: The job has a result: 4f4366e88b164c13b5a8752023e59bb1",
"Information: 0: Workflow Done: Run"
]
}
But when it hits Format Date to convert to SQL smalldatetime, I get the error on the server saying it is expecting a datetime, when it very much is receiving a datetime.
{
"start": "2023-06-28T18:55:16.484736Z",
"end": "2023-06-28T18:55:16.4925068Z",
"traces": [
"Error: 0: Unexpected Error: VertiGIS.Workflow.Runtime.Execution.Exceptions.ActivityExecutionException: [WF: Activity execution error] Failed to execute activity 11 with action gcx:wf:core::FormatDate: [WF: Activity input error] Input date was invalid. Expected type date time",
" ---> VertiGIS.Workflow.Runtime.ActivityInputException: [WF: Activity input error] Input date was invalid. Expected type date time",
" at VertiGIS.Workflow.Runtime.Activities.Core.FormatDate.Execute(IDictionary`2 inputs, IActivityContext context)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteActivityHandler(IActivityHandler handler, IDictionary`2 inputs)",
" --- End of inner exception stack trace ---",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteActivityHandler(IActivityHandler handler, IDictionary`2 inputs)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteFinish(IActivityHandler handler, IDictionary`2 inputs)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteStart()",
" at VertiGIS.Workflow.Runtime.Execution.AmbientState.ExecuteCurrentContext()",
" at VertiGIS.Workflow.Runtime.Execution.AmbientState.Execute()",
" at VertiGIS.Workflow.Runtime.Execution.Engine.Run(Program program, RunOptions options)",
" at VertiGIS.Workflow.Hosts.Server.Host.RunWorkflow(String workflowJson, IDictionary`2 inputs, IDictionary`2 trivia, String accessToken, String portalUrl, CancellationToken cancellationToken)",
" at VertiGIS.Workflow.Server.Foundation.WorkflowRunner.ProcessAsync(Object content)"
]
}
Note that this was working last week, and now it is not.
Nothing was changed since then with the workflow, the wf designer app config, the mobile app config, the database, or the Studio server.
-
And If I just bypass the Format Date activity to feed the Unix epoch timestamp directly to the SQL insert, pictured below, I get the error, listed further below.

{
"start": "2023-06-28T19:04:40.7720798Z",
"end": "2023-06-28T19:04:40.795218Z",
"traces": [
"Error: 0: Unexpected Error: VertiGIS.Workflow.Runtime.Execution.Exceptions.ActivityExecutionException: [WF: Activity execution error] Failed to execute activity 5 with action gcx:wf:server::SqlNonQuery: No mapping exists from object type Newtonsoft.Json.Linq.JValue to a known managed provider native type.",
" ---> System.ArgumentException: No mapping exists from object type Newtonsoft.Json.Linq.JValue to a known managed provider native type.",
" at System.Data.SqlClient.MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen, Boolean streamAllowed)",
" at System.Data.SqlClient.MetaType.GetMetaTypeFromType(Type dataType)",
" at System.Data.SqlClient.SqlParameter.GetMetaTypeOnly()",
" at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)",
" at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters)",
" at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc)",
" at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)",
" at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)",
" at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)",
" at System.Data.SqlClient.SqlCommand.BeginExecuteNonQuery(AsyncCallback callback, Object stateObject)",
" at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)",
" at System.Threading.Tasks.TaskFactory`1.FromAsync(Func`3 beginMethod, Func`2 endMethod, Object state)",
" at System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)",
"--- End of stack trace from previous location ---",
" at VertiGIS.Workflow.Server.Activities.SqlNonQuery.ExecuteQuery(String provider, CancellationToken cancellationToken)",
" at VertiGIS.Workflow.Server.Activities.SqlQueryBase.Execute(IDictionary`2 inputs, IActivityContext context)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteActivityHandler(IActivityHandler handler, IDictionary`2 inputs)",
" --- End of inner exception stack trace ---",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteActivityHandler(IActivityHandler handler, IDictionary`2 inputs)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteFinish(IActivityHandler handler, IDictionary`2 inputs)",
" at VertiGIS.Workflow.Runtime.Execution.ActivityContext.ExecuteStart()",
" at VertiGIS.Workflow.Runtime.Execution.AmbientState.ExecuteCurrentContext()",
" at VertiGIS.Workflow.Runtime.Execution.AmbientState.Execute()",
" at VertiGIS.Workflow.Runtime.Execution.Engine.Run(Program program, RunOptions options)",
" at VertiGIS.Workflow.Hosts.Server.Host.RunWorkflow(String workflowJson, IDictionary`2 inputs, IDictionary`2 trivia, String accessToken, String portalUrl, CancellationToken cancellationToken)",
" at VertiGIS.Workflow.Server.Foundation.WorkflowRunner.ProcessAsync(Object content)"
]
}This error occurs whether I include the datetime field or not. So, it seems to be a more general SQL Server type error.
I confirmed that all this had worked on June 19th, last week. Nothing was changed since then with the workflow, the mobile app config, the database, or the Studio server.
UPDATE:
- I found the cause to this issue, unrelated to the the datetime and Format Date issues.
- It was because I was passing an object instead of a string.
- I changed $getWorkflowInputs1.inputs.attributes["UID"] to parseInt($getWorkflowInputs1.inputs.attributes["UID"].toString()) in my insert parameters and it worked with the one UID field (excluded datetime and all other fields for now).
- DISREGARD: It is stranger because this worked last week, but is there a better way to cast that because I expect UID to be an integer, but I have to do that big runaround of pass the integer as an object to the server workflow and then cast object -> string -> integer.
- I found that using $getWorkflowInputs1.inputs.attributes["UID"].value gets the correct data type as well; that's more straightforward.
1 -
Alright, turned out these issues are related. It is working now; I am passing my attributes to the server workflow and inserting records in a separate non-spatial database.
When I pass the datetime to the Format Date activity, I need to append that .value to get the datetime out of the object.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer