Skip to main content
August 4, 2025
Solved

Create blank record type with all fields initialised

  • August 4, 2025
  • 18 replies
  • 0 views

With CDTs I can do something like this to initialise a CDT with all fields set to blank/null

cast(
  'type!{urn:com:appian:types}CustomType',
  {}
)

Is anyone aware of a similar approach with records? Casting {}, null(), or a!map() to a record type just returns null

In this use case I won't know the field names to be able to use them. I only have the record type

**Edit: Adding more context

If the record type has fields A, B and c then each of those fields needs to be set with null/blank (which is what would happen with the CDT).

eg the value returned is recordType!CustomType(a: null, b: null, c: null)

Best answer by shubhama926776

Got you!
There's no direct equivalent for Record Types. Unlike CDTs, you cannot initialize a record type with all fields set to null without knowing field names.

If you want to set fields explicitly, you must do it field-by-field like this:

recordType!Employee(
  name: "",
  age: null,
  email: ""
)

18 replies

shubhama926776
August 4, 2025

Use the record type constructor with empty parentheses:

recordType!YourRecordType()

This creates a record instance with all fields set to null/default values, similar to cast() with CDTs.

August 4, 2025

This doesn't work. It simply returns a blank record type. None of the fields are initialsed

shubhama926776
August 4, 2025

Got you!
There's no direct equivalent for Record Types. Unlike CDTs, you cannot initialize a record type with all fields set to null without knowing field names.

If you want to set fields explicitly, you must do it field-by-field like this:

recordType!Employee(
  name: "",
  age: null,
  email: ""
)

harshas2775
August 4, 2025

You are correct! To work with local variables of record type we need to reference record fields using reference everywhere needed. 

In this use case I won't know the field names to be able to use them. I only have the record type

Typing in recordtype!recordName.fields.... is the only way to know the field names and use with local variables indexing.

I personally try to work as much as possible with rule inputs instead of local variables Or, call a reusable constructor rule instead of ad-hoc expressions wherever needed! 

stefanhelzle0001
August 4, 2025

Why is that important? What do you want to achieve?

August 4, 2025

Validation of payload from external systems before writing the data, eg if payload from external system doesn't match the record type / CDT being written then return a 400.

With older apps that use CDTs, we can store the type #, then get the keys from a blank initialised CDT (using the cast method above) and compare it to the keys in the JSON payload.

With records, it seems we'd need store all the record field names to be able to compare them, which makes it more difficult to manage in the long run if fields change with code changes.

stefanhelzle0001
August 4, 2025

OK. Thanks.