How to update a recordType records with updateDictionary/update functions?

Certified Senior Developer

Hi,

I've already used the updatedictionary and update functions with CDT, but how it works with RecordType? Could you show me the correct syntax please ?

/* works fine with CDT */
  local!dataVehicles: a!queryEntity(...),

  local!vehicles: a!forEach(
    items: local!dataVehicles,
    expression: a!update(
      data: fv!item, 
      index: {
        "id",
        "model"
      }, 
      value: {
        1,
        fv!item.model
      }
    )
  )
  
/* does not work */
  local!dataVeh: a!queryRecordType(
    recordType: 'recordType!Vehicles',
    fields: {
      'Vehicles.fields.id',
      'Vehicles.fields.model'
    },
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
  ).data,

  local!vehicles: a!forEach(
    items: local!dataVeh,
    expression: a!update(
      data: fv!item['recordType!Vehicle'], 
      index: {
        'recordType!Vehicle.fields.id',
        'recordType!Vehicle.fields.model'
      }, 
      value: { 
        1,
        fv!item.model
      }
    )
  )
  
/* Does not work */
  local!vehicles: a!forEach(
    items: local!dataVeh,
    expression: updatedictionary(
      dictionary: fv!item['recordType!Vehicle'], 
      fieldsAndValues: {
        fv!item['recordType!Vehicle.fields.id']: 1,
        fv!item['recordType!Vehicle.fields.model']: "my model"
      }
    )
  )


Best regards

  Discussion posts and replies are publicly visible

Parents
  • Hi!

    The syntax is fine but calling the record directly doesn't return the data of that record.
    You need to query the record type to return the data of the record type.

    This could be a possible solution: in items, you can put the function queryRecordType() instead of the record type itself.

    local!vehicles: a!forEach(
        items: a!queryRecordType(
            recordType: 'recordType!Vehicle',
            pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
        ).data,
        expression: a!update(
            data: fv!item['recordType!Vehicle'], 
            index: {
                'recordType!Vehicle.fields.id',
                'recordType!Vehicle.fields.model'
            }, 
            value: { 
                1,
                fv!item.model
            }
        )
    )
    

Reply
  • Hi!

    The syntax is fine but calling the record directly doesn't return the data of that record.
    You need to query the record type to return the data of the record type.

    This could be a possible solution: in items, you can put the function queryRecordType() instead of the record type itself.

    local!vehicles: a!forEach(
        items: a!queryRecordType(
            recordType: 'recordType!Vehicle',
            pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
        ).data,
        expression: a!update(
            data: fv!item['recordType!Vehicle'], 
            index: {
                'recordType!Vehicle.fields.id',
                'recordType!Vehicle.fields.model'
            }, 
            value: { 
                1,
                fv!item.model
            }
        )
    )
    

Children