Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 932387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:39:37+00:00 2026-05-15T20:39:37+00:00

I have a datawindow containing multiple fields. I want to write a validation expression

  • 0

I have a datawindow containing multiple fields. I want to write a validation expression for a field named amount. I have another two fields named debit and credit. If the sum of debit and credit is greater than amount, then I want to show a validation message to the user.

How can I write the required validation expression in the Column Specification of that datawindow?

I also want to write validation expression for a field named test. There is a field named criteria. When this field is set to 1, I want the test field to be a required field. How can I write validation expression for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:39:38+00:00Added an answer on May 15, 2026 at 8:39 pm

    There are different ways to do this, depending on whether you have to use the column’s required validation expression or have the license to do it different ways.

    Design Considerations

    Is this going to be a freestyle datawindow where you only need to validate the rule once for the screen, or a tabular style where users can mass enter sets of data and the rule needs to be applied to each row?

    Do you want to require the users to enter the correct values each time a required field gets focus or do you want to let them freely navigate the screen and validate at save time?

    You’ll get some different responses here, I expect, but I prefer to use the column specification expressions only for simple checks because:

    • Complicated logic in there tends to get hard to read and maintain
    • If you have multiple error conditions you’re checking for, that can lead to some unwieldy messages if you use the column specification’s built-in error message field

    However, I’ll grant that dw expressions are generally really fast.

    Using a Computed Field for Validation Rules

    One alternative technique is also a fast performer and can be used in most versions of PB.

    • Have a computed field on the datawindow that has a meaningful name such as cf_amount_rule and something like this in the expression: if (debit + credit = amount, 0, 1)
    • Make that field invisible to the user if you want
    • Add another computed field in the footer to sum cf_amount_rule and you now have a handy reference point that quickly tells you when there is an error
    • At save time (or the pfc_validation event for PFC users) you can check for sum > 0 and post an error message

    OO purists might suggest that it’s wrong to put logic in the datawindow and if you find yourself putting in the same rule in multiple datawindows that’s certainly a code smell. But for simple rules that are unlikely to change I have found time and again that the datawindow is very efficient at running these rules and saving you from having to write lots of code elsewhere.

    Optional Goodies

    • You can make the error message more robust by using the find() functionality to identify specific rows with the error
    • You provide useful visual cues to your users by changing the row or a field’s background color via property expressions that reference cf_amount_rule.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datawindow where I have a date field. I want to specify
I have a datawindow(let its name be parent), in which I am displaying another
I have two master-detail datawindow which are linked through pfc's linkage service. Now I
I have a grid datawindow with a picture in it's background (with dimensions of
I have a master-detail window. In the detail window when I change a field
I have 2 tables; item_in(item_id,unit) item_out(item_id,unit) Now let say I want to know how
Have finally got a responsive site working (of a fashion). What I want to
I have a javascript function in which I want to open a new window
I have a rails app . I have created a sessionscontroller and want to
I have a table containing pipes that are installed at a location. Installed dates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.