Skip to main content

Frontend Commands Reference

Frontend commands (feCommand) are actions that the form viewer executes after receiving your runEvent response. Use these commands to control the user interface from your backend.

Commands Overview

CommandDescription
OpenRecordOpen a form in modal or new tab
ShowMessageDisplay notification to user
DownloadTrigger file download
ReloadWidgetRefresh a specific widget
CloseFormClose the current form
RedirectToNavigate to a URL
RefreshFormReload the entire form
UpdateFormDataUpdate specific form fields

OpenRecord - Open a Form

Opens a form for viewing or editing a record. Can be displayed in a modal window or new tab.

Command Structure

{
"command": "OpenRecord",
"args": {
"id": "unique-request-id",
"pluginCode": "NONE",
"formCode": "CUSTOMERFORM",
"guid": "new",
"pGuid": null,
"isFormEditorMode": false,
"originator": null,
"parent": null,
"folderData": null,
"prefillData": {
"fieldName": "prefillValue"
}
}
}

Parameters

ParameterTypeRequiredDescription
idstringYesUnique identifier for this request (use Guid.NewGuid() or uniqid())
pluginCodestringYesPlugin code (usually "NONE")
formCodestringYesCode of the form to open
guidstringYesRecord ID to load, or "new" for new record
pGuidstringNoParent record GUID
isFormEditorModebooleanNoSet to true to open in editor mode
originatorobjectNoInformation about the originating widget
parentobjectNoInformation about the parent form
folderDataobjectNoFolder context for hierarchical forms
prefillDataobjectNoDictionary of field values to prefill

Examples

// Open new customer form
feCommands.Add(new
{
command = "OpenRecord",
args = new
{
id = Guid.NewGuid().ToString(),
pluginCode = "NONE",
formCode = "CUSTOMERFORM",
guid = "new",
pGuid = (string)null,
isFormEditorMode = false,
originator = (object)null,
parent = (object)null,
folderData = (object)null,
prefillData = new Dictionary<string, string>
{
{ "status", "New" },
{ "country", "US" },
{ "createdDate", DateTime.Now.ToString("yyyy-MM-dd") }
}
}
});

// Open existing order for editing
feCommands.Add(new
{
command = "OpenRecord",
args = new
{
id = Guid.NewGuid().ToString(),
pluginCode = "NONE",
formCode = "ORDERFORM",
guid = orderId,
pGuid = customerId,
isFormEditorMode = false,
originator = (object)null,
parent = (object)null,
folderData = (object)null,
prefillData = (object)null
}
});

ShowMessage - Display Notification

Displays a notification message to the user. Supports different message types with appropriate styling.

Command Structure

{
"command": "ShowMessage",
"args": {
"type": "success",
"message": "Operation completed successfully!"
}
}

Parameters

ParameterTypeRequiredDescription
typestringYesMessage type: "success", "error", "warning", "info"
messagestringYesMessage text to display

Examples

// Success message
feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "success", message = "Customer saved successfully!" }
});

// Error message
feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "error", message = "Failed to save customer. Please try again." }
});

// Warning message
feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "warning", message = "This action cannot be undone." }
});

// Info message
feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "info", message = "Please complete all required fields." }
});

Download - Trigger File Download

Initiates a file download for the user. The file must be accessible from the server.

Command Structure

{
"command": "Download",
"args": {
"fileName": "customer-report.pdf",
"filePath": "/path/to/file.pdf"
}
}

Parameters

ParameterTypeRequiredDescription
fileNamestringYesName of the file to download (shown to user)
filePathstringYesServer file path or URL to the file

Examples

// Download a generated report
var reportPath = await GenerateCustomerReport(customerId);
feCommands.Add(new
{
command = "Download",
args = new
{
fileName = $"customer-report-{customerId}.pdf",
filePath = reportPath
}
});

// Download from S3 URL
feCommands.Add(new
{
command = "Download",
args = new
{
fileName = "invoice.pdf",
filePath = "https://mybucket.s3.amazonaws.com/invoices/invoice-123.pdf"
}
});

ReloadWidget - Refresh a Widget

Reloads a specific widget, triggering its initialization events (e.g., onTableLoadData for datatables).

Command Structure

{
"command": "ReloadWidget",
"args": {
"widgetName": "customerstbl"
}
}

Parameters

ParameterTypeRequiredDescription
widgetNamestringYesName of the widget to reload (lowercase)

Examples

// Reload a datatable after inserting a record
feCommands.Add(new
{
command = "ReloadWidget",
args = new { widgetName = "customerstbl" }
});

// Reload multiple widgets
feCommands.Add(new
{
command = "ReloadWidget",
args = new { widgetName = "orderstbl" }
});

feCommands.Add(new
{
command = "ReloadWidget",
args = new { widgetName = "summarychart" }
});

CloseForm - Close Current Form

Closes the currently open form. Useful after successful save operations.

Command Structure

{
"command": "CloseForm",
"args": {}
}

Examples

// Close form after saving
await _dbContext.SaveChangesAsync();

feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "success", message = "Customer saved successfully!" }
});

feCommands.Add(new
{
command = "CloseForm",
args = new { }
});

RedirectTo - Navigate to URL

Redirects the user to a different URL. Can be used for navigation after operations.

Command Structure

{
"command": "RedirectTo",
"args": {
"url": "/forms/customers"
}
}

Parameters

ParameterTypeRequiredDescription
urlstringYesURL to navigate to (relative or absolute)

Examples

// Redirect to customer list
feCommands.Add(new
{
command = "RedirectTo",
args = new { url = "/forms/customers" }
});

// Redirect to dashboard
feCommands.Add(new
{
command = "RedirectTo",
args = new { url = "/dashboard" }
});

// Redirect to external URL
feCommands.Add(new
{
command = "RedirectTo",
args = new { url = "https://example.com/success" }
});

RefreshForm - Reload Entire Form

Reloads the entire form, triggering all initialization events. Use when you need to refresh all data.

Command Structure

{
"command": "RefreshForm",
"args": {}
}

Examples

// Refresh form after complex updates
feCommands.Add(new
{
command = "RefreshForm",
args = new { }
});

Chaining Multiple Commands

You can execute multiple commands in sequence. They will be executed in the order they appear in the array.

// Example: Save, show message, reload table, and close form
await _dbContext.SaveChangesAsync();

// Show success message
feCommands.Add(new
{
command = "ShowMessage",
args = new { type = "success", message = "Customer saved successfully!" }
});

// Reload the customer table
feCommands.Add(new
{
command = "ReloadWidget",
args = new { widgetName = "customerstbl" }
});

// Close the form
feCommands.Add(new
{
command = "CloseForm",
args = new { }
});

Best Practices

  1. Order matters - Commands execute sequentially
  2. Always provide feedback - Use ShowMessage to inform users
  3. Close after save - Use CloseForm after successful save operations
  4. Reload affected widgets - Use ReloadWidget to refresh data
  5. Handle errors - Show error messages when operations fail

Next Steps