Looking for examples of server-side workflows
I'm looking for examples of server-side workflows and for user experiences.
I just created a simple server-side workflow to test the concept.
-
Nico,
The only I have right now is to send an mail with attachments.
Erik
0 -
Hi Nico,
I don't have any great examples on hand, but here's some of the use cases that I've run into so far:
- populate form elements using queries to SQL database tables instead of REST resources
- run batches of reports and write all the files out to a specified folder (task automation)
- cases where we need the end output for the workflow be a file download instead of the typical feature selection, feature update, or report (ie, using Create Download activity)
0 -
Has anyone been able to find any available examples of server-side Run SQL Query workflows referencing client side workflow input? While there's plenty of documentation I can't seem to find any actual workflow examples?
James
0 -
I'm attaching a quick example for the first use case I'd mentioned "populate form elements using queries to SQL database tables instead of REST resources". It's not a fleshed out sample, just an example of how to make the process work.
It looks like I can only attach one workflow at a time at the moment, so this'll be a 3-part post. This first one is the "client" workflow that you'd run directly from the viewer. You would update the Run Workflow and Get Form Element Items From Collection activities in the Autocomplete and Dropdown subworkflows in order to reference your own url for the server workflows, and to correct the field names for your data.
0 -
(continued)
This one is the server workflow referenced by the Autocomplete's Run Workflow activity. When you import it, make sure to use Info > Workflow Type to set it to a server workflow. The Run SQL Query activity uses a connection config name that I set up on "C:\ProgramData\Geocortex\Workflow\databasesettings.json" like this:
{ "DatabaseSettings": { "ConnectionStrings": { "SQLDatabase": "Data Source=support4;Initial Catalog=mydb;Integrated Security=False;User ID=myid;Password=mypassword;" } } }Alternatively, you could fill in the Connection String property like this instead of using Connection Config Name:
Data Source=support4;Initial Catalog=mydb;Integrated Security=False;User ID=myid;Password=mypassword;0 -
(continued)
This one is the server workflow referenced by the Dropdown's Run Workflow activity. When you import it, make sure to use Info > Workflow Type to set it to a server workflow. The same comments above apply for the connection information.
0 -
Thanks Amanda - this is perfect. Much appreciated!
James
0 -
Hi Nico and Amanda,
Would it be possible to send me an example of a server workflow that runs a simple SQL Query. I currently have a query setup that runs without errors however it never returns any results. It gives me the follow error when I try to print the output to the log - The given expression could not be evaluated: $sqlQuery1.dataTable.row[0]['FIELD1']. Cannot read property '0' of undefined
My sql statement in the command is super simple: SELECT 'Test1' AS FIELD1, 'Test2' AS FIELD2
Thanks, Bryan0 -
Hi Bryan Price , I think you might only need to correct the word “row” in your expression. It should be “rows” (plural) instead, ie.
$sqlQuery1.dataTable.rows[0]['FIELD1']Here's the workflow I used to test logging a field value from a SQL query. If you save this text to a JSON file, you can import it in workflow designer:
{"_properties":{"isServerWorkflow":true},"components":[{"id":2,"steps":[{"id":3,"inputs":{},"position":"0,0","purpose":"start","title":"Start","transitions":[{"id":5,"inputs":{},"position":"90,60 90,170","target":{"id":4}}]},{"action":"gcx:wf:server::SqlQuery","id":4,"inputs":{"commandText":"SELECT TOP (1000) * FROM [SupportGeoData].[SupportGeoData].[CRAYONTIME2]","connectionString":"Server=REDACTED; User Id=REDACTED; Password=REDACTED;TrustServerCertificate=True;","providerName":"Microsoft SQL Server"},"name":"sqlQuery1","position":"-30,170","title":"Sql Query","transitions":[{"id":13,"inputs":{},"position":"90,230 90,290","sourceConnector":"bottom","target":{"id":12},"targetConnector":"top"}]},{"action":"gcx:wf:core::ConvertDataTableToFeatureSet","id":10,"inputs":{"dataTable":{"accessors":["$sqlQuery1"],"annotations":[{"count":10,"index":0,"kind":"idref"}],"code":"$sqlQuery1.dataTable","source":"$sqlQuery1.dataTable"}},"name":"convertDataTableToFeatureSet1","position":"-30,380","title":"Convert Data Table To Feature Set","transitions":[{"id":19,"inputs":{},"position":"90,440 90,490","target":{"id":22}}]},{"action":"gcx:wf:core::Log","id":12,"inputs":{"message":{"accessors":["$sqlQuery1"],"annotations":[{"count":10,"index":0,"kind":"idref"}],"code":"$sqlQuery1.dataTable.rows[0]['COLOR']","source":"$sqlQuery1.dataTable.rows[0]['COLOR']"}},"position":"-30,290","title":"Log","transitions":[{"id":14,"position":"90,320 90,380","target":{"id":10}}]},{"action":"gcx:wf:core::SetWorkflowOutput","id":22,"inputs":{"name":"outputFeatures","value":{"accessors":["$convertDataTableToFeatureSet1"],"annotations":[{"count":30,"index":0,"kind":"idref"}],"code":"$convertDataTableToFeatureSet1.featureSet","source":"$convertDataTableToFeatureSet1.featureSet"}},"position":"-30,490","title":"Set Workflow Output"}]}],"designerVersion":"5.50.0+14","licenseInfo":{"licenseUrl":""},"start":{"id":3}}0 -
Thanks Amanda Frech, I really appreciate this. I was able to modify your example and get it to work!
You were correct I should have used It should be “rows” (plural). Also, the connection string needed TrustServerCertificate=True; even though it wasn't error out, I think.
Server=REDACTED; User Id=REDACTED; Password=REDACTED;TrustServerCertificate=True;
Thanks again,
Bryan
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
10 Kommentare