Skip to main content
Brainy
Jul 15, 2024 3:51 PM UTC
Solved

how to cast list of Text type to Record type

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. 

    yogip3177Answer
    Brainy
    Jul 16, 2024 4:14 AM UTC
    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
    Participating Frequently
    Jul 15, 2024 4:41 PM UTC

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

    Brainy
    Jul 15, 2024 4:59 PM UTC

    okay, I will try 

    stefanhelzle0001
    Brainy
    Jul 15, 2024 5:48 PM UTC

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

    Brainy
    Jul 15, 2024 6:29 PM UTC

    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
    Brainy
    Jul 15, 2024 7:50 PM UTC

    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
    Brainy
    Jul 16, 2024 4:14 AM UTC
    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
    )
    Brainy
    Jul 16, 2024 4:40 AM UTC

    thank you it worked