How to Create a Web Reviewer URL in a Windchill Workflow
To enable users to participate in a the review process, it may be necessary to have a workflow generate a Web Reviewer URL that is then sent to the reviewer. This workflow would typically be initiated on a state change defined in an OIR. While every workflow changes based on specific use cases, the following will detail how to configure the Expression Robot within an overall workflow.
-
Deploy
titania.properties
as described in the “Windchill Context Menus” section. It is not necessary to also deploy the context menus. -
Modify
. This will be used to build the rules based URL.titania.properties
by coping and pasting theWebReviewURL
property to a newWebReviewBaseURL
property. Remove the “?docNbr=” from theWebReviewBaseURL
property -
Create a Workflow variable called
workflowVariable
as ajava.lang.String
. The resulting link will be set into this variable. -
Within a Workflow template, add an Execute Expresssion task. Set the name to “Generate Web Reviewer URL” or something meaningful.
-
In the Expression tab, copy the below code and past into the Expression dialog. Verify all is good by clicking the Check Syntax button.
When this workflow is executed, the resulting URL will be set into
the workflowVariable
, which can then be used in
a downstream task such as sending emails.
Simple vs Rules-based URL
There are two options for generating a URL. One URL simply passes
the URL with the document number of the document to be reviewed. This
enables reviewers to review the document at any time without any constraints.
With rules-based review, the reviewer can only review the document
within the rules defined within the workflow. To switch from simple
to rules-based, simply set the useRules
variable
to true
.
Currently, reviewExpDate
is the only available
constraint which prevents reviewers from submitting comments once
past the date specified in the reviewExpDate
. The
date is based on the reviewers local date.
Constructing a Rules-Based Web Reviewer URL
The encoded expiration date is passed with the document number
in the Web Reviewer URL in the rules parameter. The value of rules is the document number and expiration date encoded as Base64.
For instance, {'docNbr':'0000120367','reviewExpDate':'20230628'}
is encoded and appears in the Web Reviewer URL as https://localhost/webreviewer?rules=eydkb2NOYnInOicwMDAwMTIwMzY3JywncmV2aWV3RXhwRGF0ZSc6JzIwMjMwNjI4J30= . The URL can be generated using the Arbortext Editor Share option.
Refer to Section 4.2 for install instructions for the Arbortext Editor
Web Collaboration application.
Programmatically Generating a Web Reviewer URL
The same code can be used to generate a Web Editor URL. However,
the Web Editor currently only supports a simple URL. Rules-based URLs
are not supported. To generate a Web Editor URL, follow the same steps
as above using the WebEditorURL
property. Make sure
to update the code appropriately.
// Using rules allows additional control of how the users can interact with Web Reviewer. boolean useRules = false; wt.epm.EPMDocument doc = (wt.epm.EPMDocument)primaryBusinessObject; String docNbr = doc.getNumber(); java.util.ResourceBundle resource = java.util.ResourceBundle.getBundle("titania"); String twrlink = ""; if (useRules) { // Get date 10 days from today. The review period will end at the end of this day based on the users local time. java.time.LocalDate today = java.time.LocalDate.now(); java.time.LocalDate dueDate = today.plusDays(10); // Format the dueDate to YYYYMMDD java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd"); String reviewExpDate = dueDate.format(formatter); // Format json String jsonString = String.format("{'docNbr':'%s','reviewExpDate':'%s'}", docNbr, reviewExpDate); //System.out.println(jsonString); // Encode the json to base64 String base64String = java.util.Base64.getEncoder().encodeToString(jsonString.getBytes()); //System.out.println(base64String); // Grab the WebReviewBaseURL from the titnaia.properties file String baseAPIURL = resource.getString("WebReviewBaseURL"); // Create the link with the encoded rules twrlink = baseAPIURL + "?rules=" + base64String; } else { // Grab the WebReviewURL from the titnaia.properties file String baseAPIURL = resource.getString("WebReviewURL"); // Create the link and set the docNbr directly in the URL twrlink = baseAPIURL + docNbr; } //System.out.println("twrlink=" + twrlink); // Set the link into a workflow variable to included in a downstream wf task workflowVariable = twrlink;