Hi Community,We have a requirement that should call a particular workflow model when a user clicks on a custom menu item (Say Publish xyz report).My queries are around the following areas:1) What would be the best approach to call the said workflow from the menu item? (Like : Should i write a JSP or a servlet that would internally do the workflow calling logic?)2) Has anyone done such an implementation? I have read the forums on WFM initiation using CSSDK but havent found a similar situation to mine.It would be really helpful if a reference to any documentation or code snippet to instantiate such a workflow.
Does anybody know what are the newjob's parameters to indicate a Model? Do such parameters even exist?
CSClient client = (CSClient) request.getAttribute("iw.csclient");CSWorkflowEngine wfEngine = client.getWorkflowEngine();CSWorkflow csWorkflow = wfEngine.createWorkflow("I_DO_NOT_KNOW_WHAT_GOES_HERE");
Don't know, but I've successfully launched workflow models from the CSSDK
However, if my workflow has a user interactive task, like approve/review/resolve errors etc, is there a way to get the screen to pop up in front of the user? I know it sounds like a far fetched idea but, if anyone has faced this issue, i would not want to reinvent the wheel!
// get the cs clientCSClient client = (CSClient) request.getAttribute("iw.csclient");//get the xml file data as a StringString fileData="Empty String"; try { File systemFile = new File(ENTER THE PATH TO workflowspecification.xml HERE); FileReader fileReader = new FileReader(systemFile); BufferedReader bufferedReader = new BufferedReader(fileReader); String line = null; fileData = ""; while ((line = bufferedReader.readLine()) != null) { fileData = fileData + line; } } catch (IOException e) { e.printStackTrace(); }//Get the workflow engine from CSClientCSWorkflowEngine wfEngine = client.getWorkflowEngine();//Now fetch the workflow from the workflow engine using fileData string as input to its createWorkflow method try { CSWorkflow csWorkflow = wfEngine.createWorkflow(fileData); out.println("Instantiated Workflow : "+csWorkflow.getName()+" with id="+csWorkflow.getId()); } catch (CSAuthorizationException e) { out.println("CSAuthorizationException occured. Error code is : " + e.getErrorCode()); e.printStackTrace(); } catch (CSRemoteException e) { out.println("CSRemoteException occured. Error code is : " + e.getErrorCode()); e.printStackTrace(); } catch (CSExpiredSessionException e) { out.println("CSExpiredSessionException occured. Error code is : " + e.getErrorCode()); e.printStackTrace(); } catch (CSException e) { out.println("CSException occured. Error code is : " + e.getErrorCode()); e.printStackTrace(); }
http:///iw-cc/command/iw.ccpro.task_details?taskid=ENTER_TASK_ID_HERE
http:///iw-cc/command/iw.ccpro.new_job?workflow_command=new_job&iw_template_file=IPM_FILE_NAME&iw_template_name=WHAT NAME YOU WANT TO SHOW ON THE TITLE&full_redirect=true&workflowType.flag=true&cwd.vpath=VPATH FROM WHERE THIS WORKFLOW WILL GET KICKED OFF
2.3->Start your workflow and choose Debug mode in it. Once you go ahead, you will be presented with 2 xmls. Copy the one in Green. This is your workflow specification xml file. Save it as a file say workflowmodel.xml...
Don't know, but I've successfully launched workflow models from the CSSDK. One could just wrap their own screen around that, but that bypasses the 'normal' instantiation screen which may or may not be the intent of the OP.@bmazum: if you would clarify what exactly you're looking for in terms of functionality, then we can recommend an approach. Your query is too general to recommend one way versus another.
I think you've already figured out most of it. My scenario went like this:* User gets a link (in an email / custom menu option / other screen / etc)* Link goes to a custom JSP, which is essentially my own "instantiation screen"* User fills out the fields and hits 'go'* Servlet receives the form post and calls iwmodelc with -i flag* The very important magic is that the first task in my workflow is an external task owned by SYSTEM/iwui where command is something that equates to a noop (e.g. 'echo')* iwmodelc will have returned a job ID. I can use this with the CSSDK to find the job and its active task, which is my "dummy" external task* Since the workflow is effectively "paused", I can update things like task variables, group task owners, etc. When I'm done, I callback the external task and the workflow gets started for real.* For bonus points, look at the task that follows my dummy external task. If that task is a CGI task and owner = $IW_USER and immediate=true, then the result of the original form post is a HTTP302 redirect to transition_task where task ID is the ID of the CGI task. (Look up URL Commands in the UI customization guide).As you mentioned, you can't pass params to iwmodelc, so configurable WFM variables won't work. If the actual model needs to change (i.e. would normally have conditional links), fire off iwmodelc in debug mode, which will produce the jobspec dynamically (safer / more flexible than generating it yourself once and storing it). You can then manipulate the jobspec as necessary before feeding it to CSWorkflowEngine.createWorkflow().One last note.. The only supported way of using the iwmodelc function is to fork a Process object to the command line tool. However, if you crack it open, you'll see that it's just a shell script that instantiates a JVM call. For performance/efficiency, I've built mine in such a way that I call the same class (com.interwoven.modeler.clt.IWModelsC) within the same JVM that is running my JSP/Servlet. It's not really supported, in that it might require adjustments after upgrades, but it's much much more efficient than forking *two* new processes.
Please provide your comments on this approach if any?
Well, it's simple and (presumably) works for your current use case, so there's that.My main concerns would be that1) it's an unsupported hack, so it may break when you upgrade and you might not be around to fix it (so document the code and your reasons thoroughly for the next person); and2) it may not be flexible enough for future needs, so you may be just delaying the effort of building a more extensive customizationBut as long as you (and your client) understand that and are comfortable with it, then there's not much else to say.