Dynamic grid .

A Score Level 1

Hi , 

I have a requirement in which the user enters any numerical value , lets say 2 , so a grid should be created with two rows.
Likewise, he can enter n values , so n rows should be created . The entries filled into these rows(grid) are to be saved into a table after submit.

please let me know the implementation.

  Discussion posts and replies are publicly visible

Parents
  • load(
      local!rowsCount,
      local!items: {},
      a!sectionLayout(
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!integerField(
                    label: "Enter No Of Rows",
                    value: local!rowsCount,
                    saveInto: {
                      local!rowsCount,
                      a!save(
                        local!items,
                        if(
                          isnull(
                            local!rowsCount
                          ),
                          {},
                          a!forEach(
                            items: repeat(
                              local!rowsCount,
                              1
                            ),
                            expression: {
                              firstName: "",
                              lastName: ""
                            }
                          )
                        )
                      )
                    }
                  )
                }
              ),
              a!columnLayout(
                contents: {}
              )
            }
          ),
          a!gridLayout(
            label: "Dynamic Grid",
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "First Name"
              ),
              a!gridLayoutHeaderCell(
                label: "Last Name"
              ),
              
            },
            rows: {
              a!forEach(
                items: local!items,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(
                      value: local!items[fv!index].firstName,
                      saveInto: local!items[fv!index].firstName
                    ),
                    a!textField(
                      value: local!items[fv!index].lastName,
                      saveInto: local!items[fv!index].lastName
                    )
                  }
                )
              )
            },
            rowHeader: 1,
            showWhen: if(
              isnull(
                local!rowsCount
              ),
              false(),
              true()
            )
          )
        }
      )
    )

  • Interface Definition: Expression evaluation error :

    hi , I am getting the above error while using this code , i have added one rule and an interface , this grid section should come below that case details section interface , is there anything that i am doing wrong ?

    load(
      local!rowsCount,
      local!items,
      local!caseDetails: if(
        isnull(
          ri!caseId
        ),
        {},
        rule!APAC_getCaseDetailsFromCaseID(
          caseId: ri!caseId
        ).data
      ),
      {
        rule!APAC_caseDetailsSectionUI(
          caseDetails: local!caseDetails
        ),
        local!rowsCount,
        local!items: {},
        a!sectionLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!integerField(
                      label: "Enter No Of Rows",
                      value: local!rowsCount,
                      saveInto: {
                        local!rowsCount,
                        a!save(
                          local!items,
                          if(
                            isnull(
                              local!rowsCount
                            ),
                            {},
                            a!forEach(
                              items: repeat(
                                local!rowsCount,
                                1
                              ),
                              expression: {
                                firstName: "",
                                lastName: ""
                              }
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {}
                )
              }
            ),
            a!gridLayout(
              label: "Dynamic Grid",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "First Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Last Name"
                ),
                
              },
              rows: {
                a!forEach(
                  items: local!items,
                  expression: a!gridRowLayout(
                    contents: {
                      a!textField(
                        value: local!items[fv!index].firstName,
                        saveInto: local!items[fv!index].firstName
                      ),
                      a!textField(
                        value: local!items[fv!index].lastName,
                        saveInto: local!items[fv!index].lastName
                      )
                    }
                  )
                )
              },
              rowHeader: 1,
              showWhen: if(
                isnull(
                  local!rowsCount
                ),
                false(),
                true()
              )
            )
          }
        )
      }
    )

  • check with this code 

    load(
      local!rowsCount,
      local!items: {},
      local!caseDetails: if(
        isnull(
          ri!caseId
        ),
        {},
        rule!APAC_getCaseDetailsFromCaseID(
          caseId: ri!caseId
        ).data
      ),
      {
        rule!APAC_caseDetailsSectionUI(
          caseDetails: local!caseDetails
        ),
        a!sectionLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!integerField(
                      label: "Enter No Of Rows",
                      value: local!rowsCount,
                      saveInto: {
                        local!rowsCount,
                        a!save(
                          local!items,
                          if(
                            isnull(
                              local!rowsCount
                            ),
                            {},
                            a!forEach(
                              items: repeat(
                                local!rowsCount,
                                1
                              ),
                              expression: {
                                firstName: "",
                                lastName: ""
                              }
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {}
                )
              }
            ),
            a!gridLayout(
              label: "Dynamic Grid",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "First Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Last Name"
                ),
                
              },
              rows: {
                a!forEach(
                  items: local!items,
                  expression: a!gridRowLayout(
                    contents: {
                      a!textField(
                        value: local!items[fv!index].firstName,
                        saveInto: local!items[fv!index].firstName
                      ),
                      a!textField(
                        value: local!items[fv!index].lastName,
                        saveInto: local!items[fv!index].lastName
                      )
                    }
                  )
                )
              },
              rowHeader: 1,
              showWhen: if(
                isnull(
                  local!rowsCount
                ),
                false(),
                true()
              )
            )
          }
        )
      }
    )

Reply
  • check with this code 

    load(
      local!rowsCount,
      local!items: {},
      local!caseDetails: if(
        isnull(
          ri!caseId
        ),
        {},
        rule!APAC_getCaseDetailsFromCaseID(
          caseId: ri!caseId
        ).data
      ),
      {
        rule!APAC_caseDetailsSectionUI(
          caseDetails: local!caseDetails
        ),
        a!sectionLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!integerField(
                      label: "Enter No Of Rows",
                      value: local!rowsCount,
                      saveInto: {
                        local!rowsCount,
                        a!save(
                          local!items,
                          if(
                            isnull(
                              local!rowsCount
                            ),
                            {},
                            a!forEach(
                              items: repeat(
                                local!rowsCount,
                                1
                              ),
                              expression: {
                                firstName: "",
                                lastName: ""
                              }
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {}
                )
              }
            ),
            a!gridLayout(
              label: "Dynamic Grid",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "First Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Last Name"
                ),
                
              },
              rows: {
                a!forEach(
                  items: local!items,
                  expression: a!gridRowLayout(
                    contents: {
                      a!textField(
                        value: local!items[fv!index].firstName,
                        saveInto: local!items[fv!index].firstName
                      ),
                      a!textField(
                        value: local!items[fv!index].lastName,
                        saveInto: local!items[fv!index].lastName
                      )
                    }
                  )
                )
              },
              rowHeader: 1,
              showWhen: if(
                isnull(
                  local!rowsCount
                ),
                false(),
                true()
              )
            )
          }
        )
      }
    )

Children
  • krishna , grid stil isn't coming. Can you please guide me ? 

    Here I am  saving grid values into policy master table .policdetails and rows are ri. policydetails Ri is of type policy master table (array type),

    grid data should be saved into policy master table aftr submit. please let me know .  

    load(
      local!rowsCount,
      local!items: {},
      local!caseDetails: if(
        isnull(
          ri!caseId
        ),
        {},
        rule!APAC_getCaseDetailsFromCaseID(
          caseId: ri!caseId
        ).data
      ),
      {
        rule!APAC_caseDetailsSectionUI(
          caseDetails: local!caseDetails
        ),
        a!sectionLayout(
          contents: {
            a!columnsLayout(
              columns: {
                a!columnLayout(
                  contents: {
                    a!integerField(
                      label: "Enter Number of Policies " ,
                      value: local!rowsCount,
                      saveInto: {
                        local!rowsCount,
                        a!save(
                          ri!rows,
                          local!rowsCount
                        ),
                        a!save(
                          ri!policyDetails,
                          cast(
                            typeof(
                              {
                                'type!{urn:aig:types:collections:APAC}CLN_SGP_POLICY_MASTER'()
                              }
                            ),
                            a!forEach(
                              items: ri!rows,
                              expression: {
                                'type!{urn:aig:types:collections:APAC}CLN_SGP_POLICY_MASTER'(
                                  policy_number: null,
                                  insured_name: null,
                                  producer_code: null,
                                  commission_amt: null,
                                  
                                )
                              }
                            )
                          )
                        ),
                        a!save(
                          local!items,
                          if(
                            isnull(
                              local!rowsCount
                            ),
                            {},
                            a!forEach(
                              items: repeat(
                                local!rowsCount,
                                1
                              ),
                              expression: {
                                policy_number: "",
                                insured_name: "",
                                producer_code:"",
                                commission_amt:"",
                              }
                            )
                          )
                        )
                      }
                    )
                  }
                ),
                a!columnLayout(
                  contents: {}
                )
              }
            ),
            a!gridLayout(
              label: "Dynamic Grid",
              headerCells: {
                a!gridLayoutHeaderCell(
                  label: "Policy Number"
                ),
                a!gridLayoutHeaderCell(
                  label: "Insured Name"
                ),
                a!gridLayoutHeaderCell(
                  label: "Producer Code "
                ),
                a!gridLayoutHeaderCell(
                  label: "Amount to Refund"
                )
              },
              rows: {
                a!forEach(
                  items: ri!policyDetails,
                  expression: a!gridRowLayout(
                    contents: {
                      a!textField(
                        value: ri!policyDetails[fv!index].policy_number,
                        saveInto: ri!policyDetails[fv!index].policy_number
                      ),
                      a!textField(
                        value: ri!policyDetails[fv!index].insured_name,
                        saveInto: ri!policyDetails[fv!index].insured_name
                      ),
                      a!textField(
                        value: ri!policyDetails[fv!index].producer_code,
                        saveInto: ri!policyDetails[fv!index].producer_code
                      ),
                      a!textField(
                        value: ri!policyDetails[fv!index].commission_amt,
                        saveInto: ri!policyDetails[fv!index].commission_amt
                      )
                    }
                  )
                )
              },
              showWhen: if(
                isnull(
                  local!rowsCount
                ),
                false(),
                true()
              ),
              rowHeader: 1
            )
          }
        ),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Submit",
              style: "PRIMARY",
              value: cons!APAC_TEXT_ACTIONS[1],
              submit: true(),
              saveInto: ri!buttonAction,
              confirmMessage: "Are you sure you want to submit?",
              
            )
          },
          align: "END"
        )
      }
    )

  • 0
    Certified Lead Developer
    in reply to ST07

    On Line 41: please try replacing "items: ri!rows", with "items: enumerate(ri!rows)"

    The way it's written currently, you will only ever create one row in your rule input CDT, instead of initializing an array based on the number entered.