Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Record Field Id

Certified Lead Developer

Hi everyone Slight smile,

I have scenario where my data is stored in Map/Dictionary.

Now this has to be stored in record.
Each field to be mapped with the respective record field.

Considering the volume, Is there a way to use the Field Id to map the value.
Example:

a!localvariables(


local!list:{
{
columnName:"Name",
recordFieldId"4567898765"
},

{
columnName:"Desc",
recordFieldId"4567856894"
},

/* Now the data to be mapped */
a!foreach(
locaL!list,
index(record,fv!item.recordFieldId,null)
)

)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Can you provide some example of the data structure you have. If your field id in map is analog to record field's field id then index should work. Yet some more details will be better 

  • 0
    Certified Lead Developer
    in reply to Harsha Sharma

    I have a grid with 30 Columns.
    All these column names are stored in Table.

    In the grid, used a!foreach to populate the headers.
    For rows, a!foreach is used for each row generation. And for each column, again a!foreach is used. So here just with index, the values to be saved in the appropriate field.

    In the picture, used an expression rule to return the recordtype!record.field based on the label.

  • Is there any way, we get the field index from table. Because we already have the Column Labels in table which is queried in the interface. If the field index is stored in table, we can use it easily. Considering the performance of displayvalue() when we have large set of columns, I am checking the possibility of taking it from the table.

  • 0
    Certified Lead Developer
    in reply to Anusuya K Mahalingam

    Let's give it a try by doing this,

    Update an Rule MCI_returnRecordFieldBasedOnLabel

    a!localVariables(
      local!fieldMap: {
        {label: "Name", field: "name"},
        {label: "Description", field: "description"},
        {label: "Status", field: "status"},
        /* Add all 30 field mappings here */
      },
    
      index(
        index(
          local!fieldMap,
          wherecontains(ri!label, local!fieldMap.label),
          {}
        ),
        "field",
        null
      )
    )


    Use this type of grid code:

    a!localVariables(
      local!columns: rule!getColumnsFromTable(), /* Your column labels from DB */
      local!data:{}, /* Your data */
    {
      a!gridLayout(
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: a!forEach(
              items: local!columns,
              expression: a!textField(
                value: index(
                  fv!item,
                  rule!MCI_returnRecordFieldBasedOnLabel(
                    label: fv!item.columnLabel
                  ),
                  null
                ),
                saveInto: {
                  a!save(
                    index(
                      fv!item,
                      rule!MCI_returnRecordFieldBasedOnLabel(
                        label: fv!item.columnLabel
                      ),
                      null
                    ),
                    save!value
                  )
                }
              )
            )
          )
        )
      )
      }
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Anusuya K Mahalingam

    Let's give it a try by doing this,

    Update an Rule MCI_returnRecordFieldBasedOnLabel

    a!localVariables(
      local!fieldMap: {
        {label: "Name", field: "name"},
        {label: "Description", field: "description"},
        {label: "Status", field: "status"},
        /* Add all 30 field mappings here */
      },
    
      index(
        index(
          local!fieldMap,
          wherecontains(ri!label, local!fieldMap.label),
          {}
        ),
        "field",
        null
      )
    )


    Use this type of grid code:

    a!localVariables(
      local!columns: rule!getColumnsFromTable(), /* Your column labels from DB */
      local!data:{}, /* Your data */
    {
      a!gridLayout(
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: a!forEach(
              items: local!columns,
              expression: a!textField(
                value: index(
                  fv!item,
                  rule!MCI_returnRecordFieldBasedOnLabel(
                    label: fv!item.columnLabel
                  ),
                  null
                ),
                saveInto: {
                  a!save(
                    index(
                      fv!item,
                      rule!MCI_returnRecordFieldBasedOnLabel(
                        label: fv!item.columnLabel
                      ),
                      null
                    ),
                    save!value
                  )
                }
              )
            )
          )
        )
      )
      }
    )

Children
No Data