In Workflow 9.1 I have a document that needs to query a SQL database using various queries depending on different template values. I've created a routing decision for the 10+ different scenarios, custom query activities for each of the queries, conditional statements to error check each completed query, and then assign activities to update template fields based on what is returned. This has created quite a bit of work as the columns the queries return are the same for all, only the syntax used to obtain them is different.
Assuming the queries return the same columns from the SELECT portion and use the same data source, what I would like is to be able to build the SQL query as a token, lets call the token %(tkQuery) for this, and then pass the final %(tkQuery) into the Custom Query activity as the entire query syntax. Then I would need to only setup the Custom Query activity, the error checking conditional statement, and the assign activity once for all current and future scenarios.
I've tried to put only a parameter in the entry box and then assign %(tkQuery) to that but it puts '' around it at runtime and thus SQL fails because of incorrect format.
I've tried various types of parameters and understand why what I am trying to accomplish fails with the way this activity currently functions.
Additionally, the custom query activity does not provide an obvious way to pass a token directly into the Custom Query entry box. I've found that if I
- put in a valid SQL query with all columns I need returned (assuming they are the same for all variations of the query token),
- run the test on the activity so it populates the query's column output tokens,
- and then replace the entire query with %(tkQuery),
that it will let me use a token as my query at runtime. Obviously I can't test the custom query activity this way but at least it works at runtime for my issue.
I also know I can write my own custom script but I would prefer to use out of the box tools to accomplish this. I understand this may be a niche need but has anyone found a better way to pass a dynamically built SQL query token into the Custom Query Activity? For Laserfiche, is there any plan to easily allow tokens to be used directly within a SQL query, without the need to pass them in as parameters?