DEV Community

Peter + AI
Peter + AI

Posted on

๐Ÿ”ฅ Understanding Uniface's `callfieldtrigger`: A Developer's Guide

๐ŸŽฏ 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
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”ง Example

callfieldtrigger "detail", FIELD1
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“Š 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:

  1. Field-Level First: It first looks for the trigger at the field level
  2. Entity-Level Fallback: If not found, it falls back to the entity level
  3. 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! ๐Ÿ’ปโœจ

Top comments (0)