In Editable grid i need to add add row link in that i am getting error

a!localVariables(
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20 
  ),
  local!gridData: a!queryEntity(
    entity: cons!BQA_Quiz_Cons,
    query: a!query(
      pagingInfo: local!pagingInfo
    ),
    fetchTotalCount: true
  ),
  a!formLayout(
    label: "Example: Add,Update, or Remove Employee Data",
    contents: {
      a!gridLayout(
        
        headerCells: {

          a!gridLayoutHeaderCell(label: "Chapter Name"),
          a!gridLayoutHeaderCell(label: "File Upload"),
          a!gridLayoutHeaderCell(label: "Description"),
          a!gridLayoutHeaderCell(label: "Total Questions")
        },

        columnConfigs: {

          a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
          a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
          a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
          a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 )

        },
        rows: a!forEach(
          items: local!gridData,
          expression: a!gridRowLayout(
            contents: {


              a!textField(
                label: "chapterName" & fv!index,
                value: fv!item.chapterName,
                saveInto: fv!item.chapterName,
                required: true
              ),

              a!fileUploadField(
                label: "fileUpload" & fv!index,
                value: fv!item.fileUpload,
                saveInto: fv!item.fileUpload,
                required:true
              ),
              a!textField(
                label: "totalQuestion" & fv!index,
                value: fv!item.totalQuestion,
                saveInto: fv!item.totalQuestion,
                required:true
              ),

              a!textField(
                label: "description" & fv!index,
                value: fv!item.description,
                saveInto: fv!item.description,
                required:true
              ),
            },
            id: fv!index
          )
        ),
        addRowlink: a!dynamicLink(
          label: "Add Employee",

            value: {
              chapterName: "",
              fileUpload: {},
              totalQuestion: "",
              description: ""
              },
          saveInto: {
            a!save(local!gridData, append(local!gridData, save!value))
          }
        ),
        rowHeader: 1
      )
    },
    buttons: a!buttonLayout(
      primaryButtons: a!buttonWidget(
        label: "Submit",
        submit: true
      )
    )
  )
)
 in this code when clicking add employee i am getting this error how to resolve this

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hello  

    You need to define the type! of your CDT before you define your fields,

    a!dynamicLink(
      label: "Add Employee",
      value: type!CDT_NAME(
        chapterName: "",
        fileUpload: {},
        totalQuestion: "",
        description: ""
      ),
      saveInto: {
        a!save(
          local!gridData,
          append(local!gridData, save!value)
        )
      }
    ),

  • a!localVariables(
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20 
      ),
      local!gridData: a!queryEntity_18r3(
        entity: cons!BQA_Quiz_Cons,
        query: a!query(
          pagingInfo: local!pagingInfo
        ),
      
      ),
      a!formLayout(
        label: "Example: Add,Update, or Remove Employee Data",
        contents: {
          a!gridLayout(
    
            headerCells: {
    
              a!gridLayoutHeaderCell(label: "Chapter Name"),
              a!gridLayoutHeaderCell(label: "File Upload"),
              a!gridLayoutHeaderCell(label: "Description"),
              a!gridLayoutHeaderCell(label: "Total Questions")
            },
    
            columnConfigs: {
    
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 )
    
            },
            rows: a!forEach(
              items: local!gridData,
              expression: a!gridRowLayout(
                contents: {
    
    
                  a!textField(
                    label: "chapterName" & fv!index,
                    value: fv!item.chapterName,
                    saveInto: fv!item.chapterName,
                    required: true
                  ),
    
                  a!fileUploadField_17r1(
                    label: "fileUpload" & fv!index,
                    value: fv!item.fileUpload,
                    saveInto: fv!item.fileUpload,
                    required:true
                  ),
                  a!textField(
                    label: "totalQuestion" & fv!index,
                    value: fv!item.totalQuestion,
                    saveInto: fv!item.totalQuestion,
                    required:true
                  ),
    
                  a!textField(
                    label: "description" & fv!index,
                    value: fv!item.description,
                    saveInto: fv!item.description,
                    required:true
                  ),
                },
                id: fv!index
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Employee",
              value: 'type!{urn:com:appian:types:BQA}BQA_QuizApplication_DT'(
                chapterName: "",
                fileUpload: {},
                totalQuestion: "",
                description: ""
              ),
              saveInto: {
                a!save(
                  local!gridData,
                  append(local!gridData, save!value)
                )
              }
            ),
            rowHeader: 1
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            submit: true
          )
        )
      )
    )
     still it is same 

  • 0
    Certified Lead Developer
    in reply to balamanchari murugadas

    In your code, you mix up two data structures. Initially, in line 6, you query data and local!gridData contains data of type datasubset. Then, in your "Add Row" link, you try to append a CDT type item to that datasubset.

  • 0
    Certified Senior Developer
    in reply to balamanchari murugadas

    what is the type of data that is being returned from your local!gridData ?

Reply Children