Issue faced while trying to persist values entered into an editable grid to a cdt

Hi.

I have a requirement where I have a paging grid which is made selectable. When I select a row, I am required to display few details from that selected row into another editable grid below and with that be able to say enter a few comments and persist them.

It works fine till here.

The main issue here is that, the details I enter in the editable grid will have to be persisted into a different cdt. I am dynamically adding the rows into the editable grid. Hence I am able to display the name in the first column from the paging grid as fv!item.name_txt.

In the paragraph field, I am trying to persist the entered comments against that row into the cdt "ri!bpChecklist_coe". The entered value is never retained but it is updated when I check in the cdt in the rule input.

Please find the code snippet below. I am unable to insert it as a code or upload it as a file due to restrictions. Sorry about that.

FYI: local!coeBpData : ri!bpChecklist_coe

         a!gridLayout(
            label: "",
            headerCells: {
             /*Removed for easy reability*/
            },
            columnConfigs: {
    /*Removed for easy reability*/
            },
            rows: {
              a!forEach(
                items: local!coeBpdata,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(
                      label: "name" & fv!index,
                      value: fv!item.name_txt,
                      required: true,
                      readOnly: true
                    ),
                    a!textField(
                      label: "item" & fv!index,
                      value: fv!item.artifactName_txt,
                      saveInto: fv!item.artifactName_txt,
                      required: true,
                      readOnly: true
                    ),
                    a!dropdownField(
                      label: "priority" & fv!index,
                      placeholderLabel: "------Select a value------",
                      choiceLabels: a!forEach(
                        cons!CHOICEVALUES_RISKRATING,
                        fv!item
                      ),
                      choiceValues: a!forEach(
                        cons!CHOICEVALUES_PRIORITY,
                        fv!item
                      ),
                      value: if(or(length(local!coeBpdata),rule!APN_isEmpty(local!coeBpdata)),"",ri!bpChecklist_coe.priority_int),
                      /*if(isnull(ri!bpChecklist_coe),"",a!forEach(ri!bpChecklist_coe.priority_int,fv!item)),*/
                      saveInto: ri!bpChecklist_coe[fv!index].priority_int
                    ),
                    a!paragraphField(
                      label: "feedback" & fv!index & fv!item,
                      value: if(or(length(local!coeBpdata)<1,rule!APN_isEmpty(local!coeBpData)),"",ri!bpChecklist_coe[fv!index].comments_txt),                     
                      saveInto: ri!bpChecklist_coe[fv!index].comments_txt
                    ),
                    a!checkboxField(
                      label: "is followed" & fv!index,
                      choiceLabels: "Is Followed?",
                      choiceValues: {
                        1
                      },
                      value: 1,
                      saveInto: ri!bpChecklist_coe[fv!index].isFollowed_int
                    )
                  }
                )
              )
            }
          )

If given as above and I try to select a row in the paging grid, I get the error "Invalid index (1) for null value of type the cdt?list". I understand why that error is displayed. Need a work around this.

Thanks in advance! Do let me know if the issue's not clear.

 

 

 

  Discussion posts and replies are publicly visible

  • Hello Sujathar

    An easy way to get the same effect of an editable grid is to show a form with all the fields from the editable grid and when a button is pressed the information is added to the second paging grid, that se one paging grid can have an edit icon and an “X” to delete it. It becomes clearer to the user what are they editing and there is more room for them to see what they are actually entering.

    If your requirement is specifically to show it on a editable grid, if I am understanding correctly your problem then seems like the error you are getting is because the list you are using Doesn’t have any value on it. So when selecting on the first grid it calls the saveInto, on which you can append 1 more cdt to the list of CDTs that is been used by the editable grid. Or something around it.

    If I am wrong a working code would really help to replicate it and give you better help.

    Jose
  • Hey Jose.

    Thanks so much for your reply.

    I am in fact appending a new CDT into the first paging grid's saveInto and showing that in the editable grid on selection of a particular row. This bit's working fine. Please check the bit I've highlighted in green.

    The issue is that in the editable grid, I have a few fields in which I need to enter some data and save it. When I try doing this, the value I type, I am unable to retain to show the user what he's typed but it gets saved into the cdt.

     

    Below is my working code:

    Below is the code for the paging grid :

    = load(
      local!search,
      local!rowData,
      local!data,
      local!gridSelection: a!gridSelection(
        selected: {},
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 3,
          sort: a!sortInfo(
            field: "name_txt",
            ascending: true
          )
        )
      ),
      local!coeBpdata: if(or(isnull(ri!bpChecklist_coe),count(ri!bpChecklist_coe)),"",ri!bpChecklist_coe),

        with(
          local!datasubset: rule!CM_QE_getAllActiveBPData(
            cons!CM_CHOICEVALUES_BPSTATUS[1],
            local!search,
            local!gridSelection.pagingInfo
          ),
          local!dataForCurrentPage: local!datasubset.data,
          {
            a!gridField(
              totalCount: local!datasubset.totalCount,
              label: "",
              columns: {
                a!gridTextColumn(
                  label: "Name",
                  field: "name_txt",
                  data: index(
                    local!datasubset.data,
                    "name_txt",
                    null
                  )
                ),
                a!gridTextColumn(
                  label: "Description",
                  field: "desc_txt",
                  data: index(
                    local!datasubset.data,
                    "desc_txt",
                    null
                  )
                ),
                a!gridTextColumn(
                  label: "Risk Rating",
                  field: "riskRating_txt",
                  data: index(
                    local!datasubset.data,
                    "riskRating_txt",
                    null
                  )
                )
              },
              value: local!gridSelection,
              saveInto: {
                local!gridSelection,
                a!save(
                  local!coeBpdata,
                  a!forEach(
                    items: index(
                      local!datasubset.data,
                      wherecontains(
                        local!gridSelection.selected,
                        local!datasubset.identifiers
                      ),
                      null
                    ),
                    expression: {
                      bpRefId_int: fv!item.bp_int,
                      name_txt: fv!item.name_txt,
                      status_int: 1,
                      createdBy_txt: loggedInUser(),
                      createdDate_date: now(),
                      
                    }
                  )
                )
              },
              selection: true,
              identifiers: if(
                rule!APN_isBlank(
                  local!datasubset.identifiers
                ),
                {},
                local!datasubset.identifiers
              )
            ),
            a!textField(
              label: "Selected Best Practice Id",
              readonly: true,
              value: if(
                length(
                  local!gridSelection.selected
                ) = 0,
                "No Best Practice selected",
                joinarray(
                  local!gridSelection.selected,
                  ", "
                )
              )
            ),

    Continuation code for the editable grid:

            if(
              rule!APN_isBlank(
                local!gridSelection.selected
              ),
              {},
              a!gridLayout(
                label: "",
                headerCells: {
                  a!gridLayoutHeaderCell(
                    label: "Name",
                    align: "LEFT"
                  ),
                  a!gridLayoutHeaderCell(
                    label: "Item Reviewed",
                    align: "LEFT"
                  ),
                  a!gridLayoutHeaderCell(
                    label: "Priority",
                    align: "LEFT"
                  ),
                  a!gridLayoutHeaderCell(
                    label: "Feedback",
                    align: "LEFT"
                  ),
                  a!gridLayoutHeaderCell(
                    label: "Is Followed",
                    align: "LEFT"
                  )
                },
                columnConfigs: {
                  a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE",
                    weight: 1
                  ),
                  a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE",
                    weight: 1
                  ),
                  a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE",
                    weight: 1
                  ),
                  a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE",
                    weight: 1
                  ),
                  a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE",
                    weight: 1
                  )
                },
                rows: {
                  a!forEach(
                    items: local!coeBpdata,
                    expression: a!gridRowLayout(
                      contents: {
                        a!textField(
                          label: "name" & fv!index,
                          value: fv!item.name_txt,
                          required: true,
                          readOnly: true
                        ),
                        a!textField(
                          label: "item" & fv!index,
                          value: fv!item.artifactName_txt,
                          saveInto: fv!item.artifactName_txt,
                          required: true,
                          readOnly: true
                        ),
                        a!dropdownField(
                          label: "priority" & fv!index,
                          placeholderLabel: "------Select a value------",
                          choiceLabels: a!forEach(
                            cons!CEMA_CHOICEVALUES_BPRISKRATING,
                            fv!item
                          ),
                          choiceValues: a!forEach(
                            cons!CEMA_CHOICEVALUES_COEPRIORITY,
                            fv!item
                          ),
                          value: if(or(length(local!coeBpdata),rule!APN_isEmpty(local!coeBpdata)),"",ri!bpChecklist_coe.priority_int),
                          /*if(isnull(ri!bpChecklist_coe),"",a!forEach(ri!bpChecklist_coe.priority_int,fv!item)),*/
                          saveInto: ri!bpChecklist_coe[fv!index].priority_int
                        ),
                        a!paragraphField(
                          label: "feedback" & fv!index & fv!item,
                          value: fv!item.comments_txt,
                        /*if(or(length(local!coeBpdata)<1,rule!APN_isEmpty(local!coeBpdata),isnull(local!coeBpdata)),"",*/
                        /*index(ri!bpChecklist_coe,"comments_txt",{})),*/
                          saveInto: ri!bpChecklist_coe[fv!index].comments_txt
                        ),
                        a!checkboxField(
                          label: "is followed" & fv!index,
                          choiceLabels: "Is Followed?",
                          choiceValues: {
                            1
                          },
                          value: 1,
                          saveInto: ri!bpChecklist_coe[fv!index].isFollowed_int
                        )
                      }
                    )
                  )
                }
              )
            )
          }
        )
      }
    )

    If you check the paragraph field in the editable grid, I am unable to retail the value I entered in "value" but when I see the "saveInto" field in the cdt, it is available.