4D Blog

Home Product Automate repetitive tasks and more with form macros!

Automate repetitive tasks and more with form macros!

October 27, 2020

Product

If you’re a fan of macros in the code editor, then 4D v18 R5 has some good news for you …  because now macros are also available in the form editor!

Let me start by telling you how useful macros can be for you. Have you ever needed to use formatting or naming rules in your application, then apply them to each new form? Or maybe you’ve had to work on existing forms created by someone else, and always need to do the exact same checks and analyses before getting started. If you’ve ever encountered one of these scenarios, then 4D v18 R5 is for you because it gives you the ability to create macros and save time on predictable, repetitive tasks.

What can a form macro do?

With a form macro, you can:

  • Modify, delete, or add a property to one or more objects
  • Add or delete one or more form objects with its associated method
  • Select or deselect form objects in the editor
  • Display a modal dialog to enter a parameter on the fly
  • Calculate the ideal position of form objects and move them
  • Create a CSS class from a form object to use as a template
  • Check that image paths in the form are valid
  • Open CSS files in your CSS editor instead to searching the files on disk
  • Check that XLIFF references have their correspondence in the XLIFF files
  • and so much more …

How to use a form macro?

Form macros are visible from the contextual menu. Host database macros are displayed first, followed by component macros. To execute a macro, simply click on the menu item.

Show the macro contextual menu in the form editor

How to Write a macro?

Macros are declared in a formMacros.json file at the first level of the Sources folder in your project. You can have macros in the host application or in project components. The code of the macro consists of a class: constructor and an onInvoke function. Macro classes are instantiated when the application is launched. When a developer calls the macro in a form, the onInvoke function is called.

For more details about all of the parameters, read the macro documentation.

Try it yourself

Some macro examples are available on GitHub which you can integrate into your applications as components to test them … and why not share your macros with us?

Discuss

Tags Form editor, Project, v18 R5, v19

Latest related posts

  • April 29, 2025

    Discover your AI-powered writing assistant in 4D Write Pro

  • April 28, 2025

    Unlock the Power of AI with 4D AIKit: Automate, Create, and Innovate

  • April 25, 2025

    Formulas in Label Wizard

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy