Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • General calculation templates

Validate grid field values in EDC/CDMS

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

Table of Contents

Validate grid values  Validate grid values between ranges

Validate grid values 


Calculation fields can be used to validate values in the grid field.


For example, this template validates the values entered in the first and second columns of the first row.

var obj = JSON.parse('{grid_variable_name}');
if (Object.values(obj[0])[0] == 1 && Object.values(obj[0])[1] == 1) {
 'The values are correct!';
} else {
 'The values are not correct!';
}


Use if/else logic to render various data validation messages.


Use if/else logic to output a number and add data validation to a calculation to display 'Warning' messages (like the one below) and other types of data validation messages.


Validate grid values between ranges


For example, this template validates the values entered and checks if the values are between the given range.

// Parse the JSON string into a JavaScript object
var obj = JSON.parse('{grid_variable_name}');

// Define the ranges for each row label
const ranges = [
  ["1st Row Label", 50, 1000],
  ["2nd Row Label", 5, 35],
  ["3rd Row Label", 10, 40],
  ["4th Row Label", 10, 40],
  ["5th Row Label", 5, 20],
  ["6th Row Label", 25, 100],
]

// Filter rows that fall outside of their specified range
const outOfRange = ranges.filter(([name, min, max], index) => {
  // Extract the value from the object based on the index
  const value = Object.values(obj[index])[0];
  // Check if the value is outside the specified range or empty
  return value !== "" && (value < min || value > max);
}).map(([name]) => name); // Extract the row label for out-of-range values


// Check if any rows are out of range
if (outOfRange.length > 0) {
  // If there are out-of-range values, construct an error message
  `Check that: ${outOfRange.join(", ")} has been entered correctly!`;
} else {
  // If all values are within range, display a success message
  "The input values seem correct";
}



  

 

  


check verify

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Check if all fields are complete (and list empty fields) in EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand