Skip to content
Part 7 of 12

Inspection Forms as Files: From Test to Production, with a Diff

IBM's Inspection Forms application keeps a form in the system where it was built. Our editor writes one revision as a file that git can compare, imports it on another system after it has shown what it will write, and checks the names that the target system must hold. A command line checks and compares the files without a system.

A coloured doodle: a small house with an orange roof on the left, a larger hall with a teal roof on the right, a dotted orange arrow from a sheet by the house through a teal gate to the hall's door, and below the gate two sheets with the same three lines circled in rose

An inspection form is usually built and tried on a test system. Then it has to reach production. IBM’s Inspection Forms application offers no export and no import of a form. So the way to production is a second build by hand: an administrator opens the production system and types the form again, with every question, every choice, every rule and every formula. A typo in that second copy is a fault that nobody tested.

mas-tools.com Inspection Form Editor moves a form as one file. This article explains what the file holds, how an import shows its effect before it writes, and how a command line checks and compares the files in a pipeline. We checked the behaviour on our test system, on the MAS 9.2 series.

One revision, one file

Export to file saves one revision of a form as a JSON file. The menu ⋮ of a revision in the list has it, and so does the bar of the editor. The file name carries the form’s number, revision and name, such as 1001-r1-Locomotive-daily-check.inspform.json.

The file is written for people and for git. It begins with the form’s own lines:

{
  "format": "fiedler-inspection-form",
  "version": 5,
  "form": {
    "name": "Locomotive daily check",
    "number": "1001",
    "revision": 1,
    "organization": "EAGLENA",
    "site": "BEDFORD",
    "type": "Inspection",
    "readConfirmation": false,
    "enableReview": false,
    "enableScan": false
  },

The head of the example file of a locomotive’s daily check: where the file came from, the form type and the three settings.

The name, the number, the revision, the organization and the site say where the file came from. An import into another place changes these lines and no other. Then the sections and the questions follow in their order, each question with its response fields and each field with its choices. After them come the rules, the formulas, the names of the form scripts, the instructions, and the names of the attachments. The rules include those on a value of a domain. A rule on a number keeps its message, its action and its target together. A choice keeps its icon by name. A field type that your administrator added, such as Comment, keeps Manage’s value in the file, and so does a type the editor does not know.

The file names everything by its content. It holds no id, no number that Manage assigns, no row stamp, no user and no date. A rule names its source and its target by their place in the outline. It matches a choice by its text, as Manage does, and a value of a domain by the value:

{
  "source": {
    "question": "1.3",
    "field": 1
  },
  "when": {
    "choice": "Fail"
  },
  "then": {
    "field": {
      "question": "1.4",
      "field": 1
    },
    "visible": true,
    "required": true
  }
},

A rule of the same file: the answer Fail on question 1.3 shows question 1.4 and makes it required.

So two exports of the same revision are equal, byte for byte. A renumbering inside Manage changes nothing in the file. When the forms live in git, a diff shows what somebody changed, and only that.

Two ways into the target system

A flow from Export to file on the test system to the form file, then to git with mtif check and mtif diff, then to production as a new form from the file or as an import as the next revisionA flow from Export to file on the test system to the form file, then to git with mtif check and mtif diff, then to production as a new form from the file or as an import as the next revision
A form travels from the test system to production as one file

On the target system, the file comes in one of two ways:

  • New form → From a file… makes a new Draft from the file. The name, the organization and the site start from the file, and you may change them. Manage gives the new form a number of its own.
  • Import as revision… in the menu ⋮ of a form makes the next revision from the file, as a Pending revision. This works on a form whose newest revision is Active or Inactive. Inspectors keep the Active revision until you activate the new one.

Both dialogs take the file from disk, or its text pasted into the box, for example from a merge request. A changed text is checked again. The editor takes a file up to 3,000 kB, so a form with a picture in its instructions fits. It writes format version 5 and reads the versions 1 to 5. A file of an older version imports, and it holds none of the newer parts.

The import says what it will do before it writes

The dialog New form from a file: the file beam-engine-lubrication.inspform.json of format version 5 is chosen, the dialog says what the import creates and that nothing stops it, and below that the name of the new form and the box Find an organization.

Before the import, the dialog says what it creates and what stops it.

The dialog reads the file and answers in sentences. It names the form and the revision that the file holds. It says what the import creates: for the beam engine round in the picture, a Draft with 3 sections, 9 questions, 9 response fields, 7 choices and 6 rules, and 1 formula. It runs the form check over the file and counts the errors, the warnings and the notes. Then it says what stops the import, or that nothing does. Nothing is written before you choose Import, and Cancel writes nothing.

An import as a revision adds the comparison with the newest revision: the questions added, changed and removed. Two cases get a line of their own. A file from another form is named with that form’s number, name and organization, and the import is still allowed. A file that holds what the newest revision holds already starts no import, because a new revision would change nothing.

Names the target system must hold

A form names things that live outside it: the meter of a meter reading field, the domain of a domain field, the document folder of an upload or a signature field, and the automation scripts that the inspection app offers as actions. On our test system, Manage stored any name in these fields without a check. A form that names a document folder the production system lacks therefore saves, and the save says nothing about it.

The import checks these names before it writes. It reads the meters, the domains, the document folders and the automation scripts of the target system as the signed-in user. Every missing name is listed with the questions that need it, and a missing name stops the import. You create the name in Manage, or you change the file, and choose it again. When your account may not read one of these lists, the import names the list and stops. An administrator then grants READ on that list, or a user who holds it imports the file.

The import also checks each field type of the file against the target system. A type the target lacks stops the import, and so does a type that the target holds for another kind of field.

What stays in the source system

The file names each attachment by its file name and its folder. The documents themselves stay in the source system. The import adds no attachment and says so, and you add the files in the editor after the import.

A few things belong to one system and stay there. The reason of a revision and its status are part of the form’s history in that system. A meter’s type and unit and a domain’s type belong to the target system, so the file names only the meter or the domain.

Check and compare without a system

mtif is the editor’s command line. It works on files alone, without a system and without a network, so it fits a pipeline that keeps forms in git.

mtif check prints the form check of a file and what an import would refuse. It also lists each meter, domain, document folder and automation script that the file needs. Only the target system can check those names, and the import does.

mtif diff prints the differences of two files in the same words as the import dialog and the editor’s comparison of revisions. Here it compares the beam engine round with its second revision, in which the limit of the oil reservoir went from 40 to 45 litres:

$ mtif diff docs/examples/beam-engine-lubrication.inspform.json docs/examples/beam-engine-lubrication-r2.inspform.json
Form (1)
  Revision: 1 → 2
Questions added (1)
  2.2 "Temperature of the crank bearing (°C)"
Rules changed (2)
  Unless 1.1 "Oil in the reservoir before the round (litres)" is >= 0 and <= 45, reject the answer with "The reservoir holds at most 45 litres.". Limit changed from 40 to 45. Message before: "The reservoir holds at most 40 litres.".
  Unless 1.2 "Oil in the reservoir after the round (litres)" is >= 0 and <= 45, reject the answer with "The reservoir holds at most 45 litres.". Limit changed from 40 to 45. Message before: "The reservoir holds at most 40 litres.".

mtif diff on the two example files of the beam engine round, as the user guide records it.

The exit codes are made for a pipeline:

Code mtif check mtif diff
0 clean: no error and no warning the files are equal
1 an error, a warning, or a reason an import would refuse the file the files differ
2 a file that cannot be read, or a wrong command line the same

Information alone, such as “The form has no type.”, leaves the code at 0, and so do the names that only the target system can check. A pipeline that runs mtif check on every changed *.inspform.json therefore stops a form with an error or a warning before anybody imports it.

A normal Manage form at the end

Whichever way the form comes in, the result is an ordinary inspection form in Manage. The editor writes through the object structure MXAPIINSPFORM as the signed-in user, which is the structure that IBM’s application uses too. When we compared every column, a form saved by the editor held the same rows as the same form saved the way IBM’s application saves it. IBM’s application opens the imported form as it opens any other, and the inspection app of Maximo Mobile reads the same records from Manage.

The rights follow Manage. An export needs READ. An import as a new form needs CREATE in Inspection Forms with INSERT and SAVE of MXAPIINSPFORM, and an import as a revision needs REVISION.

What comes next

The user guide walks through an export and both imports step by step: Inspection forms as files. The commands and their options are in The command line mtif. The next article is about formulas: Formulas with a Safety Net. The mas-tools.com Inspection Form Editor page lists the whole series.

Do you want to move your own forms from test to production this way? Get in touch.

IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.

← Back to mas-tools.com Inspection Form Editor

See the tools on your own data.

Ask us for a price, a trial licence or a demo. We work in English and German.