Parsware
All articles

Parsware Platform

Custom code travels in the solution

A custom app or control is part of its solution, code and all. We exported Visitors from Development with its visitor board, its badge field and its web resources, imported it into Test, and watched an altered copy of the same file get refused.

A new visitor form in the Test environment with the badge field showing B-3301 beside a teal VISITOR badge, next to the title "Custom code travels in the solution"

Over the last few articles the Visitors solution picked up code: the visitor board app, the badge field control and the badge page. All of it was built in Development. Test should get it the way it gets everything else: export, import, done, with nothing to set up outside the platform.

What the solution holds

The solution's overview lists the custom code beside the tables and the apps:

The Visitors solution overview in Development with the Custom Controls tab showing Badge field, nw_badge_field, among tabs for Tables, Apps, Saved Queries, Custom APIs, Custom Apps and Web Resources

We raised the version to 1.5.0 with Set version and selected Export. The file that comes down carries the code itself, not a pointer to it:

  • The custom app and the control each travel as their package, the same archive that was uploaded, with its version and a SHA-256 hash of its content.
  • The web resources travel as their content, text as text and images as Base64, each with its own hash.
  • The form carries its binding to the badge field, and the Front desk app comes too.

An altered file is refused

Before importing the real file, we changed one character in the middle of the control's archive and imported that into Test:

The Solutions list in Test with an error: The package for nw_badge_field in this solution file is not the one that was exported: it no longer matches the hash recorded with it. Export the solution again and import that file unchanged. Nothing was kept: what had been imported was removed again.

The archive no longer matched the hash recorded at export, so the import stopped. It also undid what it had already done: Visitors in Test was still 1.4.0 afterwards. A damaged download, a merge gone wrong or an edit by hand all look the same here, and none of them reaches Test.

The real file

The unchanged file imported in one step:

The Solutions list in Test with Visitors from Northwind Traders now at version 1.5.0, Managed

Test now has the badge field, at the same version as Development:

The Custom Controls list of the Visitors solution in Test: Badge field, nw_badge_field, substitutes for Text, version 1.0.0

And in Test's Front desk app, a new visitor gets the badge field, served from Test:

A new visitor form in Test's Front desk app: Name Mary Jackson, Company Langley Research, and the badge field holding B-3301 beside a teal VISITOR B-3301 badge

Nobody uploaded anything to Test, and nothing points back at Development or at the machine the control was built on. Each environment serves its own copy.

What we fixed

The refusal used to say that "the stored package does not match its recorded content hash". Nothing had been stored, which made it read like a fault in Test rather than in the file. It now says the file isn't the one that was exported, and to export again. A web resource in the same state said only "content hash mismatch", behind a heading about an invalid manifest; it now says the same thing as the control.

Good to know

  • Raise the version before each export. An import refuses a version lower than the one already installed, and the version is how Test tells you which build it has.
  • The hash protects the file between export and import. It isn't a signature: it shows the file wasn't changed, not who made it. Who may import into Test and Production is still a decision about people.
  • A control registered from a dev server doesn't travel. It has no package, which is why the platform only allows it in Development. The next article is about exactly that.

Try it

Export a solution with a custom app or control in it, import it into another environment and open the app there. Then change one character of a package in the file and import it again.

Next: Hot reload while you develop.