4D Blog

Home Product Use 4D Write Pro documents as input forms

Use 4D Write Pro documents as input forms

June 2, 2020

Product

Do you want to avoid users accidentally modifying a particular 4D Write Pro document (fully or partially)? Are you interested in keeping some parts of a document untouched (e.g., giving users the ability to fill in fields in a non-disclosure agreement while ensuring that none of the information in the document is altered or changed in any way)? If you’re nodding your head, then keep reading! 4D v18 R3 lets you keep parts of your documents protected, or in other words: “non-editable“.

HDI: 4DWP document protection

In the example below, we’ve created a form using a 4D Pro document where the protected and unprotected areas are clearly identifiable (enterable areas shown in white, unchangeable areas shown in gray):

Two steps are used to define protection in a document:

  • First step- Define which part of the document will be protected or not (by default all parts will be protected).
  • Second step – Activate the document protection flag so that the first settings are taken into account.

New attributes

How to proceed? A new command isn’t needed, because two new attributes have been created to be used with the well-known command, WP SET ATTRIBUTES: wk protected and wk protection enabled. The first attribute (wk protected) can be set to almost any kind of target belonging to a document (e.g., paragraph, table, section, rows in a table, anchored pictures, etc.). Inheritance will be managed, so if you protect a section, there’s no need to protect paragraphs of this section because they’ll be protected by default. However, it’s worth noting that you can also unprotect a single paragraph inside of a protected section.

Keep in mind

The only thing you need to pay attention to is the order of the targets … which makes perfect sense. For example, if you protect a section, you can always unprotect a paragraph within that section. But the opposite is not true. If you protect a paragraph and then unprotect the section to which it belongs, the protection of the paragraph will be lost.

Code sample

You have a document that must be fully protected except for a couple of areas that must be filled in by the end user. Here’s how to set up this document:

// set full parts of document protected
WP SET ATTRIBUTES(WParea;wk protected;wk true)
// then remove protection on three ranges based on bookmarks
$range:=WP Bookmark range(WParea;"Name")
WP SET ATTRIBUTES($range;wk protected;wk false)
$range:=WP Bookmark range(WParea;"Firstname")
WP SET ATTRIBUTES($range;wk protected;wk false)
$range:=WP Bookmark range(WParea;"City")
WP SET ATTRIBUTES($range;wk protected;wk false)
// Finally activate the document protection
WP SET ATTRIBUTES(WParea;wk protection enabled;wk true)

In order to see a demonstration of this feature, check out the HDI above and the documentation.

 

Discuss

Tags 4D Write Pro, v18 R3, v19, Word processor

Latest related posts

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

  • April 29, 2025

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

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • 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 Google Listbox Logs Mail 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 Google Listbox Logs Mail 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