Unable to update grid data to database

Hi All -

I've few editable columns in my grid, on click of a submit button, my data which appears on the grid should store into a database table.

steps followed:

1. created a rule input of CDT type, where as on form load my rule input shows null, but grid displays data.

2. used the below line of code to update my database.

a!writeToDataStoreEntity(cons!PTR_DSE_FUNCTION_TEAM,ri!funcDetails)

it's not working for me. Can someone pls help me how to achieve this. I am new to APPIAN, hence request you to share in details.

 

thanks,

Mp

  Discussion posts and replies are publicly visible

Parents
  • Getting the below error:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = PCOE0ETG] : An error occurred while executing a save: Expression evaluation error at function fn!error [line 13]: The valueToStore parameter of a!writeToDataStoreEntity() cannot be null or empty.
  • Hi, it seems that ri!funDetails is empty when you pass the value into write to datastore entity. please check the value of ri!funcDetails when submit button is clicked
  • you can pass the query entity rule which returns funcDetails CDT in the rule input value.
  • I used the below line of code and it didn't work for me.
    ri!funcDetails : {rule!G_HC_GetAllFunctionTeam()}

    pls guide me as I am a beginner in APPIAN.
  • = load(
      local!employees:ri!employees,
      local!deletedEmployeeIds,
      a!formLayout(
        label: "Employee Details",
        contents: {
          a!gridLayout(
            totalCount: count(
              local!employees
            ),
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "Emp ID"
              ),
              a!gridLayoutHeaderCell(
                label: "Name"
              ),
              /* For the "Remove" column */
              a!gridLayoutHeaderCell(
                label: ""
              )
            },
            /* Only needed when some columns need to be narrow */
            columnConfigs: {
              a!gridLayoutColumnConfig(
                width: "DISTRIBUTE",
                weight: 3
              ),
              a!gridLayoutColumnConfig(
                width: "DISTRIBUTE",
                weight: 3
              ),
              a!gridLayoutColumnConfig(
                width: "ICON"
              )
            },
            /*
            * a!forEach() will take local!employee data and used that data to loop through an
            * expression that creates each row.
            *
            * When modifying the recipe to work with your data, you only need to change:
            * 1.) the number of fields in each row
            * 2.) the types of fields for each column (i.e. a!textField() for text data elements)
            * 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
            */
            rows: a!forEach(
              items: local!employees,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(
                    /* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
                    label: "emp Id " & fv!index,
                    value: fv!item.employeeId,
                    saveInto: fv!item.employeeId,
                    required: true
                  ),
                  a!textField(
                    label: "name " & fv!index,
                    value: fv!item.employeeName,
                    saveInto: fv!item.employeeName,
                    required: true
                  ),
                  a!imageField(
                    label: "delete " & fv!index,
                    images: a!documentImage(
                      document: a!iconIndicator(
                        "REMOVE"
                      ),
                      altText: "Remove Employee",
                      caption: "Remove " & fv!item.pId & " " & fv!item.pId,
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          if(
                            isnull(
                              fv!item.pId
                            ),
                            {},
                            a!save(
                              local!deletedEmployeeIds,
                              append(
                                local!deletedEmployeeIds,
                                fv!item.pId
                              )
                            )
                          ),
                          a!save(
                            local!employees,
                            remove(
                              local!employees,
                              save!value
                            )
                          )
                        }
                      )
                    ),
                    size: "ICON"
                  )
                },
                id: fv!index
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Employee",
              /*
               * For your use case, set the value to a blank instance of your CDT using
               * the type constructor, e.g. type!Employee(). Only specify the field
               * if you want to give it a default value e.g. startDate: today()+1.
               */
              value: {
                pId: "",
                employeeId: "",
                employeeName: ""
              },
              saveInto: {
                a!save(
                  local!employees,
                  append(
                    local!employees,
                    save!value
                  )
                )
              }
            ),
            rowHeader: 1
          ),
          a!textField(
            label: "New Employees",
            labelPosition: "ADJACENT",
            value: joinarray(
              index(
                local!employees,
                where(
                  a!forEach(
                    local!employees,
                    isnull(
                      fv!item.pId
                    )
                  )
                ),
                {}
              ),
              char(
                10
              )
            ),
            readOnly: true
          ),
          a!textField(
            label: "Deleted Employees",
            labelPosition: "ADJACENT",
            value: local!deletedEmployeeIds,
            readOnly: true
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            submit: true,
            saveInto: {
              a!save(ri!employees,local!employees),
              a!writeToDataStoreEntity(dataStoreEntity: cons!TEST_EMPLOYEE_ENTITY,
            valueToStore: ri!employees)}
          )
        )
      )
    )

  • thanks a lot chandhinir for the sample code :) let me try and confirm.
Reply Children
No Data