How to set a default value to column in editable grid, by using addRowLink which is using empty instance of CDT type as its value?

Hi,

Am trying to set default value to a column in editable grid, am using "addRowLink" to add a new row in editable grid by click of the link I need to a default value to column in the grid (Created_By - which is hidden). In the value: attribute of 'addRowLink' am using a blank instance of CDT type, so in this case how can i set default value to a field (Created_By) in the referenced CDT for each added row in Editable grid.

load(
  local!questionsDataset: a!queryEntity(
    entity: cons!TEST_QUESTIONS_MAPPING,
    query: a!query(
      selection: a!querySelection(
        columns: {
          a!queryColumn(
            field: "Id"
          ),
          a!queryColumn(
            field: "DC_Question_Group"
          ),
          a!queryColumn(
            field: "TEST_Question_Group"
          ),
          a!queryColumn(
            field: "Created_By"
          ),
          a!queryColumn(
            field: "Created_On"
          )
        }
      ),
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20,
        sort: a!sortInfo(
          field: "Created_On",
          ascending: true
        )
      )
    )
  ),
  with(
    a!formLayout(
      label: "Duckcreek - TEST Question Mapping",
      instructions: "This interface is to map the DC & TEST Questions",
      contents: {
        a!gridLayout(
          totalCount: count(
            local!questionsDataset.data
          ),
          headerCells: {
            a!gridLayoutHeaderCell(
              label: "Id"
            ),
            a!gridLayoutHeaderCell(
              label: "DC Qn Group"
            ),
            a!gridLayoutHeaderCell(
              label: "TEST Qn Group"
            ),
            /* For the "Remove" column */
            a!gridLayoutHeaderCell(
              label: ""
            )
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE",
              weight: 0.5
            ),
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE",
              weight: 5
            ),
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE",
              weight: 5
            ),
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE",
              weight: 1
            )
          },
          rows: a!forEach(
            items: local!questionsDataset.data,
            expression: a!gridRowLayout(
              contents: {
                a!integerField(
                  label: "Id " & fv!index,
                  value: fv!item.Id,
                  saveInto: fv!item.Id,
                  readOnly: true()
                ),
                a!textField(
                  label: "DC Qn Group " & fv!index,
                  value: fv!item.DC_Question_Group,
                  saveInto: fv!item.DC_Question_Group,
                  required: true
                ),
                a!textField(
                  label: "TEST Qn Group " & fv!index,
                  value: fv!item.TEST_Question_Group,
                  saveInto: fv!item.TEST_Question_Group,
                  required: true
                ),
                a!textField(
                  label: "Created By " & fv!index,
                  value: fv!item.Created_By,
                  saveInto: fv!item.Created_By,
                  showWhen: false()
                ),
                a!imageField(
                  label: "delete " & fv!index,
                  images: a!documentImage(
                    document: a!iconIndicator(
                      "REMOVE"
                    ),
                    altText: "Remove Employee",
                    caption: "Remove " & fv!item.Id,
                    link: a!dynamicLink(
                      value: fv!index,
                      saveInto: {
                        a!save(
                          ri!questionsToUpdate,
                          remove(
                            ri!questionsToUpdate,
                            save!value
                          )
                        )
                      }
                    )
                  ),
                  size: "ICON"
                )
              },
              id: fv!index
            )
          ),
          addRowlink: a!dynamicLink(
            label: "Add Group",
            value: 'type!{urn:wipro:TEST:appian:TESTintegration}TEST_Questions_Mapping'(),
            saveInto: {
              a!save(
                local!questionsDataset.data,
                append(
                  local!questionsDataset.data,
                  save!value
                )
              )
            }
          )
        ),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidgetSubmit(
              label: "Submit",
              style: "PRIMARY",
              saveInto: {
                a!save(
                  ri!questionsToUpdate,
                  local!questionsDataset.data
                )
              }
            )
          },
          secondaryButtons: {
            a!buttonWidgetSubmit(
              label: "Cancel",
              style: "NORMAL",
              value: true,
              saveInto: ri!cancel,
              skipValidation: true
            )
          }
        )
      }
    )
  )
)

 

Regards,

Balaji.R

  Discussion posts and replies are publicly visible

Parents Reply
  • If the value has already be set and you want to set it to null before saving it, you can use the updatecdt() function which is available as a plugin. If you cannot deploy that plugin, you could create an expression that you pass the entire cdt into and return cdt with the id value set to null by returning a "dictionary" with all the cdt values mapped except for the fields you want to set to null (or any other value).

    Create an expression similar to below with an input of type CDT you want to manipulate and use an apply() or forEach() to loop thru your array:
    = {
    id: null(),
    name: ri!input.name,
    status: ri!iinpu.status,
    value: ri!input.value}

    Bryant
Children
No Data