Name of the WebApp

pWriteNVR

 

What does this WebApp do?

in a Traveller Step, it allows you to write NVR values to a formatted Word document.

Supppose that you want to generate a quality assurance document in the last step of a Traveller, you can use this WebApp to make a Word document showing key NVR values such as measurements and specs. The generated Word document is based on a formatted template Word document in which the NVRs values are written. So the resulting Word document will have a nice layout and formatting including for example the company logo, additional information and disclaimers,

 

Requirements

  • EZ-MES release 4083 or newer
  • Python 3.62 or newer and CGI on EZ-MES server side

 

Configuration

The first configuration step to to make a Word document that will serve as a Template document for the generated Word documents. This file is uploaded to EZ-MES as a document.

In the second configuration step, an Event is added to a Traveller step that will call the pWriteNVR WebApp to generate the Word document and return a download link for this document. 

 

First configuration: Word Template 

Here is how a Word Template for this WebApp looks like:


pWriteNVR 00 DC 01


The following variables are automatically replaced by the pWriteNVR App:

<%FR%>: The Traveller number

<%UID%>: The UID of the Part

<%NV: [NV-Number]%>: A NV number where [NV-Number] is your NV number. This format allows you to define multiple NVs and by doing so write multiple NV values to the Word document.

 

In the Word Template example above, the traveller number, the part UID and two NVRs are written to the Word file. The two NVRs are the values of NV 'NV19-000000025' and NV 'NV19-000000026'.

 

Next, this Word Template file needs to be uploaded to EZ-MES as a Document. The resulting Document number is needed in the next configuration step (in this example,  the Document number is 'DC19-000000009'.

pWriteNVR 00 DC 02

 

Second configuration: Make an event to run the pWriteNVR WebApp

The next step is to define and add an Event to a Traveller Step. This Event will run the pWriteNVR WebApp to generate the Word document and store the download link for the Word document as a NVR in the Traveller Step.

As the download link is stored as a NVR, first a NV has to be added in the Step Definition of the Traveller Step. This is shown below:

pWriteNVR 01 SD 05

Please make sure that the name of this NV starts with the string "URL" and is of type "Text". By doing so, the NVR value will be clickable so that the generated Word document can be downloaded by simply clicking on its URL value. You will need the NV number when configuring the event in the next step. In this example, the NV number is "NV19-000000027";

 

 Next, you need to define an Event as shown below:

pWriteNVR 01 SD 01

A - Set (1) the Action Type to 'API', (2) the Content Type to 'application/json' , (3) the Method to 'POST', (4) the API Type to 'Text' and (5) the Return Type to 'JSON'.

 

B - In the URL Field, enter:

https://[YOUR DOMAIN]/WebApps/pWriteNVRs/ez_api_write_nvrs.py

YOUR DOMAIN = the main URL of your EZ-MES application (in our example: acme.eazyworks.com).

 

C - You need to add the following EZ-MES Pre-Defined Variables:

[FR] = -- Current Part Traveler Number --

[UID] = -- Current Part UID --

 

D - Next, click on the input ICON on the right side of the POST BODY field in to get a bigger input window,

pWriteNVR 01 SD 02

 Enter in the POST BODY:


{
"FR": "[FR]",
"UID": "[UID]",
"PATH": "Upload\\[FR]\\",
"FILE": "your_file_name_[UID]",
"USER": "your_user_name",
"KEY": "your_passkey",
"OUTPUT": "docx",
"TEMPLATE": "your_document_number_for_Word_Template",
"TEMPLATE_REV": "A",
"NV_RESULT": "your_NV_number_for_download_link"
}


Please note that the variables [FR] and [UID] will be automatically replaced by their actual values at that moment in time. In this example, the UID value is also used in the name of generated the Word file and the FR value is used as the name of a subfolder beneath the Upload folder where to store the Word document. By doing so, the generated Word documents will have a better organizational structure.

 

 Next, you need to make a trigger that always fires when a Traveller Step is entered:

pWriteNVR 01 SD 03

 

Next, you can use the Action and the Trigger you just made, to make an Event:

pWriteNVR 01 SD 04

 

The final step is to add this event to the Step Definition of the Traveller where you want to generate the Word document (attach Event to Traveller):

pWriteNVR 01 SD 06

 

Running the pUploadNVRs WebApp

After the Word Template document has been uploaded to EZ-MES as a document file and the Event to run the pWriteNVR Webapp has been configured an added to the correct Step Definition, a Word document with the NVRs can be generated in a Traveller Step.

 

First, start the Traveller, assign an UID to it and in our example below, set two NV values for 'Value-A' and 'Value-B-NR'.

pWriteNVR 02 FR S1

 

When the Traveller is moved to the next step, the Word document is generated automatically in the background and the download link for this file is shown.

pWriteNVR 02 FR S2A

 

By clicking on the download link, the Word document is downloaded and next, can be opened:

pWriteNVR 02 FR S2B