Skip to main content
July 15, 2024
Solved

how to cast list of Text type to Record type

  • July 15, 2024
  • 9 replies
  • 0 views

hi, 

I have a some data stored in a local variable which is of type ( Text List ) , this has the fields similar to a record type and I wanted to update the database.

if I pass the local variable to process model , I get an error due to different types.

how to cast the local variable to record type. Any help is appreciated. 

    Best answer by yogip3177
    You can try the following way:
    a!localVariables(
      local!data: { "A", "B", "C" },
      local!records: a!forEach(
        items: local!data,
        expression: 'recordType!Record Type Name'(
          'recordType!Record Type Name.fields.field Name': fv!item
        )
      ),
      local!records
    )

    9 replies

    karumurua531442
    July 15, 2024

    hi [mention:92ba06295fbc4d77b281c512999a858b:e9ed411860ed4f2ba0265705b8793d05]  you can do it using cast( yourRecordtype, local!variable),

    July 15, 2024

    okay, I will try 

    stefanhelzle0001
    July 15, 2024

    I have difficulties understanding your situation. A list of text does not have any "field names". Can you help us with some details?

    July 15, 2024

    I am having an editable grid and saving the rows to a local variable. the rows in the table is the union between two tables , I have to update the table back with the selected rows. 

    local variable has exactly the same fields as the record type

    stefanhelzle0001
    July 15, 2024

    Sorry, but with that level of details, I cannot even guess what you are doing, or try to help you understand and solve the issue.

    A while ago, I recorded a podcast episode about how the get great answers here: appian.rocks/.../

    yogip3177Answer
    July 16, 2024
    You can try the following way:
    a!localVariables(
      local!data: { "A", "B", "C" },
      local!records: a!forEach(
        items: local!data,
        expression: 'recordType!Record Type Name'(
          'recordType!Record Type Name.fields.field Name': fv!item
        )
      ),
      local!records
    )
    July 16, 2024

    thank you it worked