Skip to main content
December 23, 2024
Solved

Populate data from one RecordType to another RecordType

  • December 23, 2024
  • 11 replies
  • 0 views

I have a RecordType STG with multiple Records in it. I need to have that data inserted/copied to another RecordType TARGET. Both have the same columns and data types defined in them.

With the exception of Unique Identifiers  (ID Column) in both the Tables, I want the rest of all columns data to be moved from STG to Target.

Can you please advise on how we can do this. I was thinking Script Task in a process model, but need some guidance on this.

Best answer by mathieud0001

You could create a rule (i.e. CopyRecords) that takes a list of the Record Type as input and returns a list of the target Record type:

a!localVariables(
  local!records: ri!S_Records_Source,
  local!recordsMap: cast(
    a!listType(typeof(a!map())),
    local!records
  ),
  local!recordsMapWithNoIdentifiers: a!update(local!recordsMap, { "id" }, { null }),
  cast(
    a!listType(
      'recordType!{e10c73fb-040d-4dc2-bd0d-64ba11097acc}S_Record_Target'
    ),
    local!recordsMapWithNoIdentifiers
  )
)

11 replies

mathieud0001
December 23, 2024

You could create a rule (i.e. CopyRecords) that takes a list of the Record Type as input and returns a list of the target Record type:

a!localVariables(
  local!records: ri!S_Records_Source,
  local!recordsMap: cast(
    a!listType(typeof(a!map())),
    local!records
  ),
  local!recordsMapWithNoIdentifiers: a!update(local!recordsMap, { "id" }, { null }),
  cast(
    a!listType(
      'recordType!{e10c73fb-040d-4dc2-bd0d-64ba11097acc}S_Record_Target'
    ),
    local!recordsMapWithNoIdentifiers
  )
)

December 23, 2024

Thank you [mention:f5e81b8502fa4e77ad12697686a4fc56:e9ed411860ed4f2ba0265705b8793d05] , I created an Expression Rule and I was getting error. 

Expression evaluation error at function 'cast' [line 3]: Could not cast from RecordType to Map. Details: CastInvalidCould not cast from RecordType to Map. Details: CastInvalid

Am I missing something here? I have attached a screenshot of the Expression Rule I have used here.

mathieud0001
December 23, 2024

1. Rule input needs to be an array.

2. You put the recordType object instead of a list of recordTypes. Should look like this.