Enable the server feature
C# runs inside the website process. A native Umbraco backoffice administrator must approve it. Ordinary form-edit permission is insufficient.
The host must deploy MegaForm.Scripting.dll and enable the server setting:
{
"MegaForm": {
"AfterSubmitScriptEnabled": true
}
}
Restart after changing the host configuration. On this local demo, the launch script enables the flag for the running process; it does not change the published configuration files.
Author, validate and approve
- Save the form first so it has an ID.
- Open Form Settings → C# scripting.
- Choose a guided sample and map its field/configuration parameters.
- Use the sample in the editor, then Check syntax.
- Use Test run with fictional input. SQL and HTTP samples perform real operations.
- Choose the enable switch, failure policy and timeout, then Save script as an administrator.
- Submit the actual public form and inspect the recorded result.
The approval is tied to the saved script. Imported or changed source must not inherit an unrelated approval. Saving the form and saving the script are separate operations.
Read data and set the response
var quantity = ctx.GetDecimal("quantity");
var unitPrice = ctx.GetDecimal("unit_price");
var total = quantity * unitPrice;
ctx.SetVariable("calculatedTotal", total);
ctx.Response.SuccessMessage = "Calculated total: "
+ total.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
The working example uses these actual field keys. Run variables do not rewrite the saved submission. At the post-commit stage, ctx.SetValue cannot change a committed answer.
Scripts use C# 7.3 body syntax with ctx and cancellation token ct in scope. Use using (...) statements rather than newer using var syntax. Pass ct to asynchronous operations.
Continue to Umbraco, SQL & HTTP recipes. For a fixed action on every submission, prefer a workflow or SQL binding first.