Skip to main content

Required (Property Keyword)

For a persistent class, specifies that the property’s value must be given a value before it can be stored to disk. For an XML-enabled class, specifies that the element to which the property is mapped is required.

Usage

To specify that the property is required, use the following syntax:

Property name As classname [ Required ];

Otherwise, omit this keyword or place the word Not immediately before the keyword.

Details

For a persistent class, this keyword specifies that the property must be given a value before the containing object can be stored to disk; an error occurs if the property does not have a value.

If a property is of type %StreamOpens in a new tab, the stream cannot be a null stream. That is, the stream property is considered to have a value if the %IsNull() method returns 0.

For a class that extends %XML.AdaptorOpens in a new tab, this keyword affects the corresponding XML schema. If a property is marked Required, then the corresponding element in the schema does not have minOccurs="0" and is thus considered required. See Projecting Objects to XML. Note that in this case, the class does not have to be a persistent class. XML schema validation occurs when InterSystems IRIS reads an XML document; see Using XML Tools.

In a subclass, you can mark an optional property as required, but you cannot do the reverse.

Notes

If a property is marked as both read-only and required, note the following difference in behavior between object access and SQL access:

  • When you save the object, InterSystems IRIS does not validate the property. This means that InterSystems IRIS ignores the Required keyword for that property.

  • When you insert or update a record, InterSystems IRIS does consider the Required keyword for the property.

Default

If you omit this keyword, the property is not required.

See Also

Purpose of this instance: Draft documentation
DocReleaseID: HealthConnect2025.1
Content loaded from:
/staging/learning/iris-doc/2025.1.x/doc/cache/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/ensemble/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthconnect/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthcommon/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/security/en-us/src/
Excluded items: AADAN, ABIT, ACLOUD, AFL_adonet, AFL_ecp, AFL_icm, AFL_jdbc, AFL_netxep, AFL_sharding, AFL_xep, APMML, APOWER, ARGATEWAY, AWEBSOCKETS, AWSGI, BJAVA, BJAVNAT, BJAVPER, BJAVXEP, BJSNAT, BNET, BNETNAT, BNETODBC, BNETXEP, BPYNAT, BSPK, BTPI, BXCI, GAUTOML, GCONV, GCSP, GICM, GIKNOW, GIML, GISQ, GISR, GSCF, GSQLSRCH, GTSQ, GUIMA, PAGE_activex, PAGE_administration, PAGE_apimgr, PAGE_appdev_ides, PAGE_bi, PAGE_cachedirect, PAGE_data_migration, PAGE_data_science, PAGE_deployment, PAGE_deployment_configuration, PAGE_deployment_containers, PAGE_deployment_icm, PAGE_deployment_iko, PAGE_deployment_install, PAGE_dotnet, PAGE_dotnet_native, PAGE_dsvr, PAGE_embedded_language_development, PAGE_epython, PAGE_external_language_development, PAGE_interop, PAGE_interop_lifecycle, PAGE_interop_vdoc, PAGE_interoperability, PAGE_java, PAGE_java_jdbc, PAGE_java_native, PAGE_machine_learning, PAGE_monitoring, PAGE_multimodel, PAGE_multimodel_multidimensional, PAGE_multimodel_object, PAGE_multivalue, PAGE_native, PAGE_nodejs_native, PAGE_objectscript, PAGE_objectscript_ides, PAGE_odbc, PAGE_platform_arch_design, PAGE_pygate, PAGE_python, PAGE_python_native, PAGE_reports, PAGE_scalability, PAGE_security_authentication, PAGE_security_authorization, PAGE_studio, PAGE_zen, PAGE_zenmojo, PAGE_zenreports
FeedbackOpens in a new tab