Create blank record type with all fields initialised

Certified Senior Developer

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)

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to nathanp119

    If I understood the requirements correctly, the function a!keys() can help you dynamically get the fields from record. Using the output you can match the keys with payload keys. Here is a sample expression for reference. 

    a!localVariables(
      local!recordData: a!queryRecordType(
        recordType: recordType!recordName,
        pagingInfo: a!pagingInfo(1, 1),
        fields: a!selectionFields(
          allFieldsFromRecordType: recordType!recordName,
          includeRealTimeCustomFields: true(),
          includeExtraLongTextFields: true(),
          selectFields: recordtype!relatedRecordFields
        )
      ).data,
      a!keys(local!recordData[1])
    )

Children