Approach to filter data after fetched from stored procedure

Want to know best approach to filter data after getting fetched from Stored procedure

  Discussion posts and replies are publicly visible

Top Replies

  • Hi there,

    This really depends on the size of the data and the type of filters you want to apply to the data.
    If the size is small, then you can iterate through the data and set 'null' where the filter turns out to be false. 
    And then at the end, reject all the null values. 

    However, I am interested in knowing more about the use case here, 

  • Sure,

    Actually in the editable grid i want to  apply the filters .. where the data subset in the grid fetch data from stored proc ... ..i cant change the stored proc because of dependents .... so wanted to know the approach to filter the data which was getting fetched from stored proc

  • 0
    Certified Lead Developer
    in reply to Klaus34

    Oh. 

    Changing the SP should not create any problem for the dependents as those new filters inputs, that you will be adding,  will only be applied when they are passed. For the rest of the cases, the SP should return a similar type of data. 

    And anyways, Appian will never recommend filtering the data on the front end, instead of doing it on the backend as it can have a performance impact on the interface/rule and may result in poor UX. 

    Let's see what other members have to say about it. 

  • Actually why i cant edit Stored proc there is one more reason .. elaborating :

    in editable grid there are so many fields like they are getting fetched from stored proc (ri!oldTestData)
    and 5 to 10 fields are there which are getting fetched from local subdocs query rule as i have mentioned below two fields .. now i want to apply the filter on first field "Defnination"

    a!local variables (
    local!SubDocData: rule!TEST_getAllSubDocEntityIdDocName(),

    local!datasubset: todatasubset(ri!oldTESTData, ri!pagingInfo)

    a!gridLayout(

    headerCells: {}

    columnConfigs:{}

    rows: a!forEach(
    items: local!datasubset,
    expression: a!gTESTRowLayout(
    id: fv!item.entity_ID,
    contents: {

    a!richTextDisplayField(
    preventWrapping :true,
    value: index(
    index(
    local!SubDocData,
    wherecontains(
    tointeger(fv!item.entity_ID),
    tointeger(local!SubDocData.entityId)
    )
    ),
    "definition",
    {}
    )),

    a!dropdownField(
    required:if(ri!isQCReview, false, true),
    placeholder: "-- Select -- ",
    choiceLabels:
    index(
    index(local!questionOptions, "value", {}),
    wherecontains(
    cons!TEST_SUB_DOC_QUESTION_IDS[2],
    tointeger(
    index(local!questionOptions, "questionId", {})
    )
    ),
    {}
    )
    ,
    choiceValues:
    index(
    index(local!questionOptions, "value", {}),
    wherecontains(
    cons!TEST_SUB_DOC_QUESTION_IDS[2],
    tointeger(
    index(local!questionOptions, "questionId", {})
    )
    ),
    {}
    )
    ,
    value: upper(fv!item.translationNeeded),
    saveInto: {
    fv!item.translationNeeded,
    a!save(
    ri!oldAnswerData[wherecontains(
    fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
    )].translationNeeded,
    save!value
    )
    },
    disabled: if(
    contains(ri!selectedIndices, fv!item.entity_ID),
    false,
    true

  • Like the other poster said, in general I recommend doing your filtering during your query because the database is much more efficient at filtering than running an expression. That being said, there are some cases where it's necessary to filter in an expression, so if you have a relatively small dataset then there are two methods I've typically used to filter on the fly:

    a!localVariables(
      local!cases: {
        a!map(
          id: 1,
          priority: "Low",
          status: "New",
          dateUpdated: today()
        ),
        a!map(
          id: 2,
          priority: "Medium",
          status: "Pending Response",
          dateUpdated: today() - 4
        ),
        a!map(
          id: 3,
          priority: "Low",
          status: "Closed",
          dateUpdated: today() - 2
        ),
        a!map(
          id: 4,
          priority: "High",
          status: "New",
          dateUpdated: today() - 1
        ),
        
      },
      
      /* Option 1*/
      a!forEach(
        items: local!cases,
        expression: if(
          fv!item.priority = "Low",
          fv!item,
          {}
        )
      ),
      
      /* Option 2 */
      index(
        local!cases,
        wherecontains(
          "Low",
          local!cases.priority
        ),
        {}
      )
    )

    Option 1 uses a!forEach() to do a comparison, so any logical statement can be used to "filter" the data. It works because a!forEach() implicitly flattens all lists, so if you provide an empty list as the response in the false case, those items are filtered out.

    Option 2 uses a combination of index() and wherecontains() that is most useful if you're specifically looking if a value exists. The where contains tells you which indexes contain that value, and then you return the corresponding indexes from your original dataset with the index() function.

  • a!localVariables(
      local!selectedEntityIdtoRemove,
      local!entityTypeId: cons!TEST_SUBMISSION_DOCUMENTS_ENTITY_TYPE_ID,
      local!questionIds: index(
        index(
          rule!TEST_getQuestionsByCaidAndEntityTypeId(
            contentAreaId: index(
              ri!contentAreaCountryVw,
              "contentAreaId",
              {}
            ),
            entityTypeId: local!entityTypeId
          ),
          "data",
          {}
        ),
        "questionId",
        {}
      ),
      local!questionOptions: if(
        or(
          isnull(local!questionIds),
          count(local!questionIds) = 0
        ),
        {},
        a!flatten(
          rule!TEST_getQuestionOptionsValueByQuestionIdHandleNull(questionId: local!questionIds)
        )
      ),
      local!dd_docTypes: cons!TEST_SUB_DOC_TYPES,
      local!filterDocType,
      local!filterDocName,
      local!CurrentPage,
      local!expandCollapseComments,
      local!datasubset: todatasubset(ri!oldAnswerData, ri!pagingInfo),
      local!selection,
      local!selectedDocument,
      local!removeIds,
      local!entityId: index(ri!oldAnswerData, "entity_ID", {}),
      local!documentData: rule!TEST_getAllRSUSubDocNotInEntityIdseDocType(entityIds: local!entityId),
    
      local!deleteDocumentIds,
    
      local!totalDataCount: count(ri!oldAnswerData),
    
      local!SubDocData: rule!TEST_getAllRSUSubDocEntityIdDefinitionsDocName(),
      local!totalNumberOfDocuments:length(trim(ri!oldAnswerData)),
      {
    
        if(
          ri!isQCReview,
          {},
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidget(
                loadingIndicator :true,
                icon:"remove",
                label: "Remove",
                saveInto: {
                  a!save(
                    ri!deletedEntityId,
                    append(
                      ri!deletedEntityId,
                      a!forEach(
                        items: ri!selectedIndices,
                        expression: 'type!{urn:com:appian:types:TEST}TEST_SubDocs_SPResultset'(
                          entity_ID: fv!item,
                          comments: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "comments",
                            {}
                          ),
                          translationNeeded: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "translationNeeded",
                            {}
                          ),
                          lecSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "lecSubmission",
                            {}
                          ),
                          cecSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "cecSubmission",
                            {}
                          ),
                          regionalRaSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "regionalRaSubmission",
                            {}
                          ),
                          countryRaSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "countryRaSubmission",
                            {}
                          ),
                          importExportLicense: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "importExportLicense",
                            {}
                          ),
                          contractNegoAndExec: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "contractNegoAndExec",
                            {}
                          ),
                          requiredForEdp: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "requiredForEdp",
                            {}
                          ),
                          euCTRPart1: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "euCTRPart1",
                            {}
                          ),
                          euCTRPart2: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "euCTRPart2",
                            {}
                          ),
    
                        )
                      )
                    )
                  ),
                  a!save(
                    local!deleteDocumentIds,
                    remove(
                      ri!oldAnswerData,
                      wherecontains(
                        ri!selectedIndices,
                        index(ri!oldAnswerData, "entity_ID", {})
                      )
                    )
                  ),
                  a!save(
                    ri!oldAnswerData,
                    local!deleteDocumentIds
                  ),
                  a!save(ri!selectedIndices, {}),
                  a!save(
                    ri!subDocs,
                    index(
                      rule!TEST_getQuesEntitiesByIds(
                        tointeger(index(ri!oldAnswerData, "entity_ID", {}))
                      ),
                      "data",
                      {}
                    )
                  ),
    
                },
                disabled: if(
                  rule!APN_isEmpty(ri!selectedIndices),
                  true,
                  false
                )
              )
            }
          )
        ),
        rule!TEST_hyperLinkgridPagination(
          pagingInfo: ri!pagingInfo,
    
          totalDataCount:local!totalNumberOfDocuments,
          CurrentPage: local!CurrentPage
        ),
        a!gridLayout(
          validations:if(ri!isQCReview,{},a!validationMessage(
            message: "A value is required . Please review and submit the form",
            validateAfter: "SUBMIT",
            showWhen: if(
              rule!TEST_validationForRequiredSubgrid(
                input: cons!TEST_SUB_DOC_grid_QUESTION_VALUES,
                oldAnswerData: ri!oldAnswerData
              ),false,true)
          )),
    
    
          labelPosition: "COLLAPSED",
          totalCount: local!totalDataCount,
          headerCells: {
            a!gridLayoutHeaderCell(label: "Doc Type"),
            a!gridLayoutHeaderCell(label: "Document Name"),
            a!gridLayoutHeaderCell(label: "Definition"),
            a!gridLayoutHeaderCell(label: "Comments"),
            a!gridLayoutHeaderCell(label: "Translation needed?"),
            a!gridLayoutHeaderCell(label: "Required for LEC submission?"),
            a!gridLayoutHeaderCell(label: "Required for CEC submission?"),
            a!gridLayoutHeaderCell(
              label: "Required for Regional RA submission?"
            ),
            a!gridLayoutHeaderCell(
              label: "Required for Country RA submission?"
            ),
            a!gridLayoutHeaderCell(label: "Required for Other submission?"),
            a!gridLayoutHeaderCell(label: "Import/Export license"),
            /* TEST 2.3 - Update Name & Remove Contract to be executed col*/
            a!gridLayoutHeaderCell(
              label: "Contract negotiation and execution documents"
            ),
            a!gridLayoutHeaderCell(label: "Required for EDP?"),
            a!gridLayoutHeaderCell(label: "EU CTR Part 1"),
            a!gridLayoutHeaderCell(label: "EU CTR Part 2")
          },
          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),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
            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!datasubset,
            expression: a!gridRowLayout(
              id: fv!item.entity_ID,
              contents: {
                a!richTextDisplayField(
                  value: if(
                    ri!isQCReview,
                    if(
                      if(
                        rule!APN_isEmpty(ri!rsuDocumentDifference),
                        false,
                        and(
                          contains(ri!rsuDocumentDifference, fv!item)/* not(
                        isnull(
                          ri!oldAnswerData[fv!index].entity_ID
                        )
                      )*/
    
                        )
                      ),
                      {
                        a!richTextIcon(icon: "ASTERISK", color: "POSITIVE"),
                        a!richTextIcon(icon: "ASTERISK", color: "POSITIVE"),
                        a!richTextItem(
                          text: {
                            index(
                              index(
                                local!SubDocData,
                                wherecontains(
                                  tointeger(fv!item.entity_ID),
                                  tointeger(local!SubDocData.entityId)
                                )
                              ),
                              "eDocType",
                              {}
                            )
                          }
                        )
                      },
                      a!richTextItem(
                        text: {
                          index(
                            index(
                              local!SubDocData,
                              wherecontains(
                                tointeger(fv!item.entity_ID),
                                tointeger(local!SubDocData.entityId)
                              )
                            ),
                            "eDocType",
                            {}
                          )
                        }
                      )
                    ),
                    a!richTextItem(
                      text: {
                        index(
                          index(
                            local!SubDocData,
                            wherecontains(
                              tointeger(fv!item.entity_ID),
                              tointeger(local!SubDocData.entityId)
                            )
                          ),
                          "eDocType",
                          {}
                        )
                      }
                    )
                  )
                ),
                a!richTextDisplayField(
                  value: index(
                    index(
                      local!SubDocData,
                      wherecontains(
                        tointeger(fv!item.entity_ID),
                        tointeger(local!SubDocData.entityId)
                      )
                    ),
                    "displayName",
                    {}
                  )
                ),
    
                a!richTextDisplayField(
                  preventWrapping :true,
                  value: index(
                    index(
                      local!SubDocData,
                      wherecontains(
                        tointeger(fv!item.entity_ID),
                        tointeger(local!SubDocData.entityId)
                      )
                    ),
                    "definition",
                    {}
                  ))
                  ,
                  if(
                    contains(ri!selectedIndices, fv!item.entity_ID),
                    a!textField(
                      value: fv!item.comments,
                      saveInto: {
                        fv!item.comments,
                        a!save(
                          ri!oldAnswerData[wherecontains(
                            fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                          )].comments,
                          save!value
                        )
                      },
                      validations: if(
                        len(fv!item.comments) > 2000,
                        "Limit your Entry to " & 2000 & " characters!",
                        null
                      )
                    ),
                    if(
                      tointeger(local!expandCollapseComments) = fv!identifier,
                      a!richTextDisplayField(
                        value: if(
                          len(fv!item.comments) > 25,
                          {
                            a!richTextItem(text: fv!item.comments),
                            a!richTextItem(
                              text: " collapse",
                              link: a!dynamicLink(
                                label: "",
                                saveInto: a!save(local!expandCollapseComments, 0)
                              ),
                              linkStyle: "STANDALONE"
                            )
                          },
                          a!richTextItem(text: fv!item.comments, )
                        )
                      ),
                      a!richTextDisplayField(
                        value: if(
                          len(fv!item.comments) > 25,
                          {
                            a!richTextItem(text: left(fv!item.comments, 25)),
                            a!richTextItem(
                              text: " expand",
                              link: a!dynamicLink(
                                label: "expand",
                                saveInto: a!save(
                                  local!expandCollapseComments,
                                  fv!identifier
                                )
                              ),
                              linkStyle: "STANDALONE"
                            )
                          },
                          a!richTextItem(text: fv!item.comments, )
                        )
                      )
                    )
                  ),
                  a!dropdownField(
                    required:if(ri!isQCReview, false, true),
                    placeholder: "-- Select -- ",
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[2],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[2],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    value: upper(fv!item.translationNeeded),
                    saveInto: {
                      fv!item.translationNeeded,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].translationNeeded,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[3],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[3],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.lecSubmission),
                    required:if(ri!isQCReview, false, true),
                    saveInto: {
                      fv!item.lecSubmission,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].lecSubmission,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[4],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[4],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    value: upper(fv!item.cecSubmission),
                    saveInto: {
                      fv!item.cecSubmission,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].cecSubmission,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[5],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[5],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.regionalRaSubmission),
                    saveInto: {
                      fv!item.regionalRaSubmission,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].regionalRaSubmission,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[6],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      )
    
                    ),
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[6],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.countryRaSubmission),
                    saveInto: {
                      fv!item.countryRaSubmission,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].countryRaSubmission,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[7],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    )
                    ,
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[7],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.otherSubmission),
                    saveInto: {
                      fv!item.otherSubmission,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].otherSubmission,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[8],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[8],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.importExportLicense),
                    saveInto: {
                      fv!item.importExportLicense,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].importExportLicense,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[9],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues:  index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[9],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    ),
                    value: upper(fv!item.contractNegoAndExec),
                    saveInto: {
                      fv!item.contractNegoAndExec,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].contractNegoAndExec,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[11],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[11],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.requiredForEdp),
                    saveInto: {
                      fv!item.requiredForEdp,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].requiredForEdp,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[12],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues:  index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[12],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
                    ),
                    value: upper(fv!item.euCTRPart1),
                    saveInto: {
                      fv!item.euCTRPart1,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].euCTRPart1,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  ),
                  a!dropdownField(
                    placeholder: "-- Select -- ",
                    required:if(ri!isQCReview, false, true),
                    choiceLabels: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[13],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    choiceValues: 
                    index(
                      index(local!questionOptions, "value", {}),
                      wherecontains(
                        cons!TEST_SUB_DOC_QUESTION_IDS[13],
                        tointeger(
                          index(local!questionOptions, "questionId", {})
                        )
                      ),
                      {}
    
                    ),
                    value: upper(fv!item.euCTRPart2),
                    saveInto: {
                      fv!item.euCTRPart2,
                      a!save(
                        ri!oldAnswerData[wherecontains(
                          fv!item.entity_ID, index(ri!oldAnswerData, "entity_ID", {})
                        )].euCTRPart2,
                        save!value
                      )
                    },
                    disabled: if(
                      contains(ri!selectedIndices, fv!item.entity_ID),
                      false,
                      true
                    )
                  )
              }
            )
          ),
          selectionValue: ri!selectedIndices,
          selectionSaveInto: a!save(
            ri!selectedIndices,
            a!flatten(save!value)
          ),
          selectable: if(ri!isQCReview, false, true),
          height: "TALL"
        ),
        if(
          ri!isQCReview,
          {},
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidget(
                loadingIndicator :true,
                icon:"remove",
                label: "Remove",
                saveInto: {
                  a!save(
                    ri!deletedEntityId,
                    append(
                      ri!deletedEntityId,
                      a!forEach(
                        items: ri!selectedIndices,
                        expression: 'type!{urn:com:appian:types:TEST}TEST_SubDocs_SPResultset'(
                          entity_ID: fv!item,
                          comments: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "comments",
                            {}
                          ),
                          translationNeeded: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "translationNeeded",
                            {}
                          ),
                          lecSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "lecSubmission",
                            {}
                          ),
                          cecSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "cecSubmission",
                            {}
                          ),
                          regionalRaSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "regionalRaSubmission",
                            {}
                          ),
                          countryRaSubmission: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "countryRaSubmission",
                            {}
                          ),
                          importExportLicense: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "importExportLicense",
                            {}
                          ),
                          contractNegoAndExec: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "contractNegoAndExec",
                            {}
                          ),
                          requiredForEdp: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "requiredForEdp",
                            {}
                          ),
                          euCTRPart1: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "euCTRPart1",
                            {}
                          ),
                          euCTRPart2: index(
                            ri!oldAnswerData[wherecontains(
                              fv!item, index(ri!oldAnswerData, "entity_ID", {})
                            )],
                            "euCTRPart2",
                            {}
                          )
                        )
                      )
                    )
                  ),
                  a!save(
                    local!deleteDocumentIds,
                    remove(
                      ri!oldAnswerData,
                      wherecontains(
                        ri!selectedIndices,
                        index(ri!oldAnswerData, "entity_ID", {})
                      )
                    )
                  ),
                  a!save(
                    ri!oldAnswerData,
                    local!deleteDocumentIds
                  ),
                  a!save(ri!selectedIndices, {}),
                  a!save(
                    ri!subDocs,
                    index(
                      rule!TEST_getQuesEntitiesByIds(
                        tointeger(index(ri!oldAnswerData, "entity_ID", {}))
                      ),
                      "data",
                      {}
                    )
                  ),
    
                },
                disabled: if(
                  rule!APN_isEmpty(ri!selectedIndices),
                  true,
                  false
                )
              )
            }
          )
        )})

    in the editable grid filters of edoctype and Displayname needs to be applied