🎯 What is callfieldtrigger
?
If you're working with Uniface applications, you've probably encountered situations where you need to explicitly call triggers on specific fields. That's where callfieldtrigger
comes to the rescue! 🚀
The callfieldtrigger
statement allows you to explicitly call detail, help, menu, or interactive triggers on a field. Think of it as your programmatic way to trigger field-level events that would normally be triggered by user interactions.
📝 Syntax & Usage
The syntax is straightforward:
callfieldtrigger TriggerName, FieldName
🔧 Example
callfieldtrigger "detail", FIELD1
📊 Parameters Breakdown
Parameter | Data Type | Description |
---|---|---|
TriggerName | String | Can be "detail", "help", "menu", or the name of a field-level interactive trigger with no parameters |
FieldName | String | The field on which the trigger should be called |
🎁 Return Values
The function returns values in $status
:
- ≥0: ✅ Success! The value returned by the trigger
- <0: ❌ Error occurred. Check
$procerror
for details
🚨 Common Error Codes
Error Code | Constant | Meaning |
---|---|---|
-1101 | PROCERR_FIELD | 🔍 Specified field does not exist |
-1120 | PROCERROR_OPERATION | ⚠️ Specified trigger doesn't exist on field or entity level |
-1123 | PROCERR_NPARAMETERS | 🎛️ Specified trigger has parameters (not allowed) |
🎮 How It Works
Here's the cool part about callfieldtrigger
:
- Field-Level First: It first looks for the trigger at the field level
- Entity-Level Fallback: If not found, it falls back to the entity level
- Menu Trigger Special Case: For menu triggers, it can even fall back to component or application level! 🎯
🖥️ DSP Widget Integration
For DSP widgets, this gets even more interesting! Users can trigger events like:
-
onclick
👆 -
ondblclick
👆👆 -
onblur
👁️ - And many more!
DSP widgets can use these events to call triggers on the fields they're bound to, creating a seamless user experience.
⚡ Key Restrictions
Important: Only triggers with no implicit processing can be called. This means:
- ❌ Triggers with parameters cannot be called
- ✅ Only parameter-less triggers are allowed
- ✅ Available in all component types
🎯 Practical Use Cases
Consider using callfieldtrigger
when you need to:
- Programmatically trigger field validations
- Show help information for specific fields
- Open context menus programmatically
- Integrate with custom DSP widgets
🏁 Conclusion
The callfieldtrigger
statement is a powerful tool in the Uniface developer's toolkit. It provides fine-grained control over field-level triggers and enables seamless integration between programmatic logic and user interface elements.
Whether you're building complex forms or integrating with DSP widgets, understanding how to properly use callfieldtrigger
can significantly enhance your Uniface applications! 🎉
📚 This article is based on the official Uniface Documentation 10.4 and was created with AI assistance to help fellow developers understand this powerful feature.
Happy coding! 💻✨