Choose the recipient before the format.
A person returning to a half-completed form needs a faithful draft. Another program needs an agreed interchange schema. A remote service needs a request it can validate. These are different handoffs even when they start from the same Data Bag.
Gramlot’s inout functions take the path of a Bag branch, so a page can export the registration without treating the visible HTML as its data model.
Save and restore preserve types.
save writes TYTX. restore asks the person to choose a file produced by save and restores typed values, including dates and decimals. It is an explicit local-file workflow, not automatic persistence.
A filename ending in .json does not change the TYTX format. Conversely, download with the json argument exports ordinary interchange data and is not the input format accepted by restore.
root.button(
"Export JSON",
action="gramlot.utl.inout.download('modulo', 'registration.json', 'json')"
)Read the explanation here. The working lesson and full contract are linked below.
Send to an application service.
sendHttp sends a Bag branch as a JSON object in an HTTP POST and resolves with the response. A status outside 200–299 rejects. The receiving service must accept the request, validate the payload and implement the business operation.
Browser origin rules, CORS and the page’s connect-src policy apply. A local file does not bypass those requirements. A returned PDF or a download link still needs a deliberate response-handling and presentation workflow.
Keep delivery explicit.
sendMail prepares a message in the person’s email program; it does not silently send mail. Long messages exceed its practical limit, so a file or HTTP handoff is more suitable for substantial forms.
An offline page does not imply a background delivery queue. Show people whether their answers are merely in memory, saved in a file or actually accepted by a service. This distinction is essential for the PDF-replacement use case.