Skip to main content

Form State

Commands that control the form's state — reloading, saving records, managing GUIDs, and server-side validation.


RedrawScreen

Force the form to refresh and redraw.

When to use: After data changes that require the entire form to reload.

JSON Response:

{
"feCommand": {
"RedrawScreen": true
}
}
if (string.Equals(widgetName, "REFRESHBTN"))
{
request.FormData["fieldName"] = "updatedValue";

response.Set("FECommand", new Dictionary<string, object>
{
["RedrawScreen"] = true
});
}

response.Set(HandlerResponse.FormData, request.FormData);

Parameters:

  • (boolean) - true to redraw, false to skip

AfterRecordSave

Close a modal form and refresh the parent form after a successful save.

When to use: After saving a record inside a modal — closes the modal and passes the new GUID back to the parent.

JSON Response:

{
"feCommand": {
"AfterRecordSave": {
"guid": "550e8400-e29b-41d4-a716-446655440000"
},
"RedrawScreen": true
}
}
if (string.Equals(widgetName, "SAVEBTN"))
{
string newRecordGuid = SaveRecordToDatabase(request.FormData);

response.Set("FECommand", new Dictionary<string, object>
{
["AfterRecordSave"] = new { guid = newRecordGuid },
["RedrawScreen"] = true
});
}

response.Set(HandlerResponse.FormData, request.FormData);

Parameters:

  • guid (string) - New record GUID to pass to the parent form
info

This command is typically paired with RedrawScreen: true to refresh the parent form after the modal closes.


ReplaceContextRecordGuid

Replace the current record GUID in the form context.

When to use: After creating a new record, update the form URL/context to reflect the new GUID instead of "new".

JSON Response:

{
"feCommand": {
"ReplaceContextRecordGuid": {
"guid": "550e8400-e29b-41d4-a716-446655440000"
}
}
}
if (string.Equals(widgetName, "CREATENEWBTN") && request.Guid == "new")
{
string newRecordGuid = Guid.NewGuid().ToString();

response.Set("FECommand", new Dictionary<string, object>
{
["ReplaceContextRecordGuid"] = new { guid = newRecordGuid }
});
}

Parameters:

  • guid (string) - New record GUID to use

FormValidationData

Display validation errors on specific form fields.

When to use: Server-side validation that needs to highlight fields with error messages.

JSON Response:

{
"feCommand": {
"FormValidationData": {
"email": "Invalid email format",
"phone": "Phone number is required",
"customerName": "Name must be at least 3 characters"
}
}
}
if (string.Equals(widgetName, "SUBMITBTN"))
{
var validationErrors = new Dictionary<string, string>();

if (string.IsNullOrEmpty(request.FormData["email"] as string))
validationErrors["email"] = "Invalid email format";

if (string.IsNullOrEmpty(request.FormData["phone"] as string))
validationErrors["phone"] = "Phone number is required";

if (request.FormData.TryGetValue("customerName", out var name) && (name as string)?.Length < 3)
validationErrors["customerName"] = "Name must be at least 3 characters";

if (validationErrors.Count > 0)
{
response.Set("FECommand", new Dictionary<string, object>
{
["FormValidationData"] = validationErrors
});
}
}

Parameters:

  • (object) - Key/value map of field names to error message strings
warning

FormValidationData clears all other commands. Validation errors stop all other form actions.