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
| Command | Description |
|---|---|
OpenRecord | Open a form in modal or new tab |
ShowMessage | Display notification to user |
Download | Trigger file download |
ReloadWidget | Refresh a specific widget |
CloseForm | Close the current form |
RedirectTo | Navigate to a URL |
RefreshForm | Reload the entire form |
UpdateFormData | Update 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
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique identifier for this request (use Guid.NewGuid() or uniqid()) |
pluginCode | string | Yes | Plugin code (usually "NONE") |
formCode | string | Yes | Code of the form to open |
guid | string | Yes | Record ID to load, or "new" for new record |
pGuid | string | No | Parent record GUID |
isFormEditorMode | boolean | No | Set to true to open in editor mode |
originator | object | No | Information about the originating widget |
parent | object | No | Information about the parent form |
folderData | object | No | Folder context for hierarchical forms |
prefillData | object | No | Dictionary of field values to prefill |
Examples
- C# / .NET
- PHP
// 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
}
});
// Open new customer form
$response['feCommand'][] = [
'command' => 'OpenRecord',
'args' => [
'id' => uniqid('', true),
'pluginCode' => 'NONE',
'formCode' => 'CUSTOMERFORM',
'guid' => 'new',
'pGuid' => null,
'isFormEditorMode' => false,
'originator' => null,
'parent' => null,
'folderData' => null,
'prefillData' => [
'status' => 'New',
'country' => 'US',
'createdDate' => date('Y-m-d')
]
]
];
// Open existing order for editing
$response['feCommand'][] = [
'command' => 'OpenRecord',
'args' => [
'id' => uniqid('', true),
'pluginCode' => 'NONE',
'formCode' => 'ORDERFORM',
'guid' => $orderId,
'pGuid' => $customerId,
'isFormEditorMode' => false,
'originator' => null,
'parent' => null,
'folderData' => null,
'prefillData' => 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
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Message type: "success", "error", "warning", "info" |
message | string | Yes | Message text to display |
Examples
- C# / .NET
- PHP
// 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." }
});
// Success message
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['type' => 'success', 'message' => 'Customer saved successfully!']
];
// Error message
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['type' => 'error', 'message' => 'Failed to save customer. Please try again.']
];
// Warning message
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['type' => 'warning', 'message' => 'This action cannot be undone.']
];
// Info message
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['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
| Parameter | Type | Required | Description |
|---|---|---|---|
fileName | string | Yes | Name of the file to download (shown to user) |
filePath | string | Yes | Server file path or URL to the file |
Examples
- C# / .NET
- PHP
// 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"
}
});
// Download a generated report
$reportPath = $this->generateCustomerReport($customerId);
$response['feCommand'][] = [
'command' => 'Download',
'args' => [
'fileName' => "customer-report-{$customerId}.pdf",
'filePath' => $reportPath
]
];
// Download from S3 URL
$response['feCommand'][] = [
'command' => 'Download',
'args' => [
'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
| Parameter | Type | Required | Description |
|---|---|---|---|
widgetName | string | Yes | Name of the widget to reload (lowercase) |
Examples
- C# / .NET
- PHP
// 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" }
});
// Reload a datatable after inserting a record
$response['feCommand'][] = [
'command' => 'ReloadWidget',
'args' => ['widgetName' => 'customerstbl']
];
// Reload multiple widgets
$response['feCommand'][] = [
'command' => 'ReloadWidget',
'args' => ['widgetName' => 'orderstbl']
];
$response['feCommand'][] = [
'command' => 'ReloadWidget',
'args' => ['widgetName' => 'summarychart']
];
CloseForm - Close Current Form
Closes the currently open form. Useful after successful save operations.
Command Structure
{
"command": "CloseForm",
"args": {}
}
Examples
- C# / .NET
- PHP
// 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 { }
});
// Close form after saving
DB::commit();
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['type' => 'success', 'message' => 'Customer saved successfully!']
];
$response['feCommand'][] = [
'command' => 'CloseForm',
'args' => []
];
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
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to navigate to (relative or absolute) |
Examples
- C# / .NET
- PHP
// 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" }
});
// Redirect to customer list
$response['feCommand'][] = [
'command' => 'RedirectTo',
'args' => ['url' => '/forms/customers']
];
// Redirect to dashboard
$response['feCommand'][] = [
'command' => 'RedirectTo',
'args' => ['url' => '/dashboard']
];
// Redirect to external URL
$response['feCommand'][] = [
'command' => 'RedirectTo',
'args' => ['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
- C# / .NET
- PHP
// Refresh form after complex updates
feCommands.Add(new
{
command = "RefreshForm",
args = new { }
});
// Refresh form after complex updates
$response['feCommand'][] = [
'command' => 'RefreshForm',
'args' => []
];
Chaining Multiple Commands
You can execute multiple commands in sequence. They will be executed in the order they appear in the array.
- C# / .NET
- PHP
// 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 { }
});
// Example: Save, show message, reload table, and close form
DB::commit();
// Show success message
$response['feCommand'][] = [
'command' => 'ShowMessage',
'args' => ['type' => 'success', 'message' => 'Customer saved successfully!']
];
// Reload the customer table
$response['feCommand'][] = [
'command' => 'ReloadWidget',
'args' => ['widgetName' => 'customerstbl']
];
// Close the form
$response['feCommand'][] = [
'command' => 'CloseForm',
'args' => []
];
Best Practices
- Order matters - Commands execute sequentially
- Always provide feedback - Use
ShowMessageto inform users - Close after save - Use
CloseFormafter successful save operations - Reload affected widgets - Use
ReloadWidgetto refresh data - Handle errors - Show error messages when operations fail
Next Steps
- Button Events - Use commands in button handlers
- Datatable Events - Use commands in table handlers
- Basic Concepts - Understanding the response structure