Initiate Workflow from REST
Comments
-
@Chris Meyer's post is probably some of the best documentation on this so far. I'm composing a Postman collection based on it, and can possibly upload it somewhere later.
-Hugh
1 -
Hello Hugh,
For completeness, here is another Gem for Workflow and REST
Say for example you want to upload a Document into the WF Attachment Volume before you start it.
How do you get the volume AttachmentID of a draft???
Well here is the answer in C#:
public long GetWorkflowDraftAttachmentVolumeID(string ticket, string ticketType, long draftProcessID) { long result = 0; var client = new RestClient(this.ContentServerURL); var request = new RestRequest("/api/v1/forms/draftprocesses/update?draftprocess_id=" + draftProcessID, Method.GET); request.AddHeader(ticketType, ticket); IRestResponse response = client.Execute(request); if (response.IsSuccessful == false) throw new Exception("GetWorkflowDraftAttachmentVolumeID REST Call Failed: StatusCode:" + response.StatusCode + " ErrorMessage:" + response.ErrorMessage); dynamic json = JObject.Parse(response.Content.ToString()); result = json.data.data_packages[0].data.attachment_folder_id; return result; }
I pieced this together from the clues, a lot from Matthew's post:
https://medium.com/driver-lane/you-might-not-need-webreports-workflow-attachments-d11852ecceb6
Regards,
-MC
I have ALL the examples if anybody needs them.
0 -
Hi Clarke, have a look here:
0 -
Hello @Chris Meyer
Thank you so much for your input on this topic. I tried to follow your instructions in order to initiate a WF with WF Attributes already completed, but we got into some issues.
We created a Draft Process, got the Draft Process ID, and wanted to use the
formUpdate
action on it, but, as described in this thread by me:We are getting the
"Could not retrieve action"
error... apparently we get this error when we try to use the Initiate action, and we also get this error when we leftdraftprocess_id
empty. We are using Postman for our tests at the moment and the WF Attribute is in a Form in the Start Step. We tried fiddling around with the request data and how we make our request but we get the same error.Do we need to make other Content Server configurations beforehand? Any kind of feedback or hint would be greatly appreciated! Thank you
0 -
WF Attribute is in a Form do you mean that you have a Form Template Object out of which a Form was made then you have associated your WF Map to the Form and the Form to the WF? or are you saying that your attribute was made using the function "Workflow Attributes" (Nothing to do with Form template or Form).It makes a **** of a difference as WF stores at index 3 WFAttributes and at Index 4 Forms so the forum readers would like to know.
0 -
@Appu Nair Our attributes are Workflow Map Attributes, created in the CS Interface from the menu Map -> Attributes, those are the ones I want to have completed before I initiate the WF.
UPDATE:
We recently tried to move this procedure from Postman to Javascript code, and it works (not much has changed from what we did in Postman). We can create a draft process, get that ID, update the values in the draft process, then initiate the draft, as described by Chris. To forum readers, I highly recommend writing code for procedures that need more than 1 request instead of using Postman.
We did this on a simple WF, that has a WF Attribute called "email", we make a draft process on this, get the draftprocess ID, update the draftprocess by adding a value for the email attribute, then initiate it. This WF then uses the value from the attribute in an Email step to send an automatic email.
0 -
I was able to do this 16.2.8 by doing this in Postman.
Call #1 =POST Content-Disposition: form-data; name="body" {"workflow_id": 2047628 } Call#2 =PUT Content-Disposition: form-data; name="body" { "draftprocess_id": 2124973, "action": "formupdate", "Values": { "WorkflowForm_2": "appu" } } Call#3 PUTContent-Disposition: form-data; name="body" {"draftprocess_id": 2124973,"action":"initiate"}
I understand this is how OT coded
- Tell the System to Generate a draft using the MAPID
- Using that draft Prepare the WF Map things like attachments & wf attributes
- Finally issue the initiate command.
Still I am not sure if you have an error or not? the place holder WorkflowForm_2 would theroretically equate to email in yours if that was the first attribute added but if there are more I frankly dont know if the mapping is missing
I take umbrage in using POSTMAN not being useful, I am a programmer who finds it very useful. More than likely what I do is I use POSTMAN understand it and then convert to JS or Java or C# or whatever .The SmartUI and Developer Tools and Fiddler also has been very useful for me. Can you install Fiddler and see if the payload you get in smartui equates to what you are doing?
I can share my Postman collection here if it is useful after trimming the server info. There were 3 distinct calls to do this WF initiate not counting getting the authtoken.
0 -
An addendum to what I posted
I had a WF attribute called NEEDED when I started my experiment and it was getting set as WorkflowForm_2
I went to my map deleted the attribute and re-added it now it is being referred internally as WorkflowForm_3
If you do an export of your map as a UTF8 file there is a function button on the map for that
you will see an assoc
{{-2,{A<1,?,'DisplayLen'=32,'DisplayName'='NEEDED','FixedRows'=true,'ID'=3,'Length'=32,'MaxRows'=1,'Name'='NEEDED','NumRows'=1,'Required'=false,'Search'=false,'Type'=-1>}
so check in your REST PUT code if you have a WorkflowForm_2 or something with a different ID
BTW this is how most OT code works if you delete an attribute the assigned number of the previous does not get used again.
"WF REST API EXPERIMENTS.docx" can be accessed via
the following link:
"WF REST API EXPERIMENTS.docx" can be accessed via
the following link:
fakeurlhttps://knowledge.opentext.com/knowledge/llisapi.dll/properties/79658365
it has the postman collection and some introductory screen caps for someone who wants to try this.
0 -
@Appu Nair Thank you for the information, we experienced this behaviour with the Workflow Forms first hand when trying to update some draft processes.
It is good to know that you can get this information when exporting the map. We also saw the Workflow Form configuration when we got WF Info on a draft process created for a Worflow.
0 -
No worries I have been working with OT categories and attributes from version 8.1.5 onwards ,the cats/atts framework and the cryptic numbers the 2,3 and so on is basically generated on the fly so since the WF Smart mechanism seems to use that in lieu of names is very much asking for trouble in my opinion as unknowingly people will delete a WF attribute and add it back then and then wonder why it is not working :) so thought of mentioning that .Even Steps in WF have the same problem so when you progress from a DEV->QA->Prod it is better to transport your artifacts so the code you tested will still work in those higher systems.
0 -
Hi @AppuNair , We are looking to fetch the attribute values of a workflow from restapi with the workflow id, able to retrieve the Attribute name via api/v2/workflows/status/processes/{workflowid} but not able to retrieve the values
0 -
@bharath_partha1 if you open a workflow in SmartView(note the intonation here is are you seeing all aspects of Workflow in smart, if at any point the interface changes to classic then this test is not valid) see if that information is provided by the smartview widgets. If it is, chances are then a RESTAPI is involved. Very few commands in smartui is implemented as Request handlers(RH's) or the old way, most smartui is executed as RESTAPI ,that is how I figured out most of the workflow code I published in the word documents
0
Categories
- All Categories
- 122 Developer Announcements
- 54 Articles
- 151 General Questions
- 148 Thrust Services
- 56 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Cloud Fax and Notifications
- 84 Digital Asset Management
- 9.4K Documentum
- 31 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 7 XM Fax
- Follow Categories