Cannot Index property of type into list of dictionary

Hi ,

I have a scenario like I have a local value

local!data :{

{id:1,name:"abc",value1:"No"},

{id:2,name:"def",value1:"No"}

}

Now I am showing this data in a grid and it can be selected so I am selecting the first row and I could able to save the entire row in a variable called

local!dataselected.

Now on click of a button say Edit.

I need to update the value of value1 which is selected to Yes from No

so on click of the button in a!save I am doing this

 

a!save(local!data.value1,updatearray(local!data.value1,wherecontains(local!selected.id,local!data.id),"Yes")

But I am facing this issues

"Cannot index the property of Cannot index property 'value1' into type List of Dictionary.

I saw a Knowledge base avialble for this but no response.

 

Can someone help me on this please.!!!

  Discussion posts and replies are publicly visible

  • Hi harshav,

    I have found the updatecdt() function works better for this type of functionality.  Do you have the CDT Manipulation plug-in installed? https://community.appian.com/b/appmarket/posts/cdt-manipulation

    Using that plugin, I mocked up an interface that provides the basic functionality you're looking for.

     

    load(
      local!pagingInfo: a!gridSelection(
        paginginfo: a!pagingInfo(
          startIndex: 1,
          batchSize: - 1
        )
      ),
      local!data: {
        {
          id: 1,
          name: "abc",
          value1: "No"
        },
        {
          id: 2,
          name: "def",
          value1: "No"
        }
      },
      {
        a!gridField(
          label: "Grid",
          totalCount: length(
            local!data
          ),
          selection: true,
          identifiers: local!data.id,
          columns: {
            a!gridTextColumn(
              label: "name",
              data: index(
                local!data,
                "name",
                null
              )
            ),
            a!gridTextColumn(
              label: "value1",
              data: index(
                local!data,
                "value1",
                null
              )
            )
          },
          value: local!pagingInfo,
          saveInto: local!pagingInfo
        ),
        a!textField(
          label: "Selection",
          value: local!pagingInfo.selected
        ),
        a!buttonLayout(
          a!buttonWidget(
            label: "Edit",
            saveInto: a!save(
              target: local!data,
              value: updatecdt(
                local!data,
                {
                  value1: updatearray(
                    local!data.value1,
                    wherecontains(
                      local!pagingInfo.selected,
                      local!data.id
                    ),
                    "Yes"
                  )
                }
              )
            )
          )
        ),
        a!paragraphField(
          value: updatecdt(
            local!data,
            {
              value1: repeat(
                length(
                  local!data
                ),
                "Yes"
              )
            }
          )
        )
      }
    )

  • Hello!

    Hope you are doing great,

    you can use the following example:

    load(
      local!data: {
        {id: 1,firstname: "Jeremie",lastname: "Romaguera",isActive: "Yes"},
        {id: 2,firstname: "Alda",lastname: "Wiza",isActive: "Yes"},
        {id: 3,firstname: "Carolyn",lastname: "Spencer",isActive: "Yes"}},
      local!selected_pagingInfo: a!gridSelection(
        selected: {},
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 5,
          sort: a!sortInfo(field: "firstname",ascending: true)
        )
      ),
      local!updatedInformation: null,
      a!formLayout(
        contents: {
          a!textField(
            label: "TEST-SELECTED VALUES",
            readOnly: true,
            value: local!selected_pagingInfo.selected
          ),
          a!gridField(
            totalCount: count(
              local!data
            ),
            columns: {
              a!gridTextColumn(
                label: "First name",
                field: "firstname",
                data: property(local!data,"firstname",null)
              ),
              a!gridTextColumn(
                label: "Last name",
                field: "lastname",
                data: property(local!data,"lastname",null)
              ),
              a!gridTextColumn(
                label: "Active ?",
                field: "isActive",
                data: property(local!data,"isActive",null)
              )
            },
            identifiers: property(local!data,"id",null),
            value: local!selected_pagingInfo,
            saveInto: local!selected_pagingInfo,
            selection: true
          ),
          a!textField(
            label: "TEST-INFORMATION UPDATED",
            readOnly: true,
            value: local!updatedInformation
          )
        },
        buttons: {
          a!buttonArrayLayout(
            buttons: a!buttonWidgetSubmit(
              label: "save",
              style: "PRIMARY",
              saveInto: {
                a!save(
                  target: local!updatedInformation,
                  value: a!forEach(
                    items: local!selected_pagingInfo.selected,
                    expression: load(
                      local!getSelectedData: index(local!data,fv!item,null),
                      a!forEach(
                        items: local!getSelectedData,
                        expression: 
                        {
                          id: property(fv!item,"id",null),
                          firstname: property(fv!item,"firstname",null),
                          lastname: property(fv!item,"lastname",null),
                          isActive: "No"
                        }
                      )
                    )
                  )
                )
              }
            )
          )
        }
      )
    )

    On this example you will find the following:

    • a list of elements showing on a data grid view.
    • selection is available.
    • once you hit on "save" button a logic will be triggered. a CDT inflight will be created updating your property "IsActive" to "No" to each selected item within your data grid view.

    I encourage to see this example, although I do not recommend using this way.

    What I recommend is the following:

    1. Avoid having this type of logic in interfaces.
      1. Use interfaces just to show or recollect information. Unless is completely necessary.
    2. Create a rule input to play with the selected data in your process model. List of integers for example.
    3. create a script task within your process model to update your CDT based on the logic aforementioned.
      1. i.e.
        1. script task - output
        2. repeat(count(pv!selectedUsers),"No")
        3. target: updatedCDT.IsActive

    I am looking forward to hearing from you, regards.

  • I believe simplest way is
    a!save(local!data.value1[ri!index],save!value)
    if there is type mismatch
    a!save(local!data.value1[ri!index],cast(typeof(local!data.value1),save!value))
  • Hi Friends,

    load(
    local!data: {
    {id: 1,firstname: "Jeremie",lastname: "Romaguera",isActive: "Yes"},
    {id: 2,firstname: "Alda",lastname: "Wiza",isActive: "Yes"},
    {id: 3,firstname: "Carolyn",lastname: "Spencer",isActive: "Yes"}},
    local!selected_pagingInfo: a!gridSelection(
    selected: {},
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(field: "firstname",ascending: true)
    )
    ),
    local!updatedInformation: null,
    a!formLayout(
    contents: {
    a!textField(
    label: "TEST-SELECTED VALUES",
    readOnly: true,
    value: local!selected_pagingInfo.selected
    ),
    a!gridField(
    totalCount: count(
    local!data
    ),
    columns: {
    a!gridTextColumn(
    label: "First name",
    field: "firstname",
    data: property(local!data,"firstname",null)
    ),
    a!gridTextColumn(
    label: "Last name",
    field: "lastname",
    data: property(local!data,"lastname",null)
    ),
    a!gridTextColumn(
    label: "Active ?",
    field: "isActive",
    data: property(local!data,"isActive",null)
    )
    },
    identifiers: property(local!data,"id",null),
    value: local!selected_pagingInfo,
    saveInto: local!selected_pagingInfo,
    selection: true
    ),
    a!textField(
    label: "TEST-INFORMATION UPDATED",
    readOnly: true,
    value: local!updatedInformation
    )
    },
    buttons: {
    a!buttonArrayLayout(
    buttons: a!buttonWidgetSubmit(
    label: "save",
    style: "PRIMARY",
    saveInto: {
    a!save(
    target: local!updatedInformation,
    value: a!forEach(
    items: local!selected_pagingInfo.selected,
    expression: load(
    local!getSelectedData: index(local!data,fv!item,null),
    a!forEach(
    items: local!getSelectedData,
    expression:
    {
    id: property(fv!item,"id",null),
    firstname: property(fv!item,"firstname",null),
    lastname: property(fv!item,"lastname",null),
    isActive: "No"
    }
    )
    )
    )
    )
    }
    )
    )
    }
    )
    )

    In the above code suppose I want to update the isActive value with different values not like fixed value"No".

    How can we achieve that,

  • AFAIK, probably create a seperate rule which will use the Update CDT