Data is not refreshed when passing from parent interface to child.

I have a parent Interface calling 2 child interfaces. Both the child interfaces are grids.  The first grid shows previously added data and has capability to select a row and add it to the bottom grid using Select button. The second grid has search fields to search for an item and add it to the grid.

I'm passing these 2 different data as 2 different variables to the Grid 2. (Though I tried passing as single didn't work).

Here is my scenario: 

  •  I select first item from Grid1 it gets added to the Grid 2
  • Then I search functionality and add data to Grid 2
  • Now I select another item from Grid1 and try to add.

Problem: This time when I select my second item from Grid 1, I don't see the newly added item in Grid 2. I see the newly added item is seen in local!submissionSubstance_HTTP but not in the Gri 2

This is the local for my Grid 1 selection 
 
  local!submissionSubstance_HTTP: a!refreshVariable(
    value:rule!DCC_castSubmissionSubstanceData(
    submissionSubstance: local!selectedSubstance_HTTP,
    submissionNumber_text: ri!submissionNumber_text,
    submissionType_text: ri!submissionType_text,
    documentId_int: ri!documentInfo_Map.id,
    folderId_int: ri!documentInfo_Map.folderId,
    indexingType_text:ri!indexingType_text
    ),
    refreshOnVarChange: local!selectedSubstance_HTTP
  ),
This is the code for overall data seen in grid

  local!indexSubstances: a!refreshVariable(
  value:if(
    and(
      rule!FARM_isNullOrEmpty(ri!substanceAdded_cdt),/*ri! for items added via Add Substance button*/
      rule!FARM_isNullOrEmpty(ri!selectedSubstance_HTTP) /*ri!for items via Grid 1 */
    ),
    {},
    if(
      rule!FARM_isNullOrEmpty(ri!substanceAdded_cdt),
      ri!selectedSubstance_HTTP,
      if(
        rule!FARM_isNullOrEmpty(ri!selectedSubstance_HTTP),
        ri!substanceAdded_cdt,
        union(ri!substanceAdded_cdt,ri!selectedSubstance_HTTP)
      )
    )
  ),
  refreshOnVarChange: ri!selectedSubstance_HTTP
  ),
  
  /*Initial data for grid*/  
  local!data1: if(                   
    rule!FARM_isNullOrEmpty(ri!documentId_int),  
    local!submissionSubstances,   
    local!documentSubstances
  ),
   

  /*Final Data to display - both Submission & Document substances*/
  local!data: a!refreshVariable(
    value: if(
      and(
        rule!FARM_isNullOrEmpty(local!data1),
        rule!FARM_isNullOrEmpty(  local!indexSubstances)
      ),
      {},
      if(
        rule!FARM_isNullOrEmpty(local!data1),
        local!indexSubstances,
        if(
          rule!FARM_isNullOrEmpty(local!indexSubstances),
          local!data1,
          union(local!data1, local!indexSubstances)
        )
      )
    ),
   
  refreshOnReferencedVarChange: not(local!refresh)
  ),

Any help is highly appreciated.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Does your expression "DCC_castSubmissionSubstanceData" use local variables? If yes, you need to use a!refreshVariable with refreshAlways set to true.

    That's a tricky behaviour of nested expressions calls.

  • 0
    Certified Associate Developer

    Hey, can you share the code snip for the grid 1 ?

  • a!localVariables(
      local!refresh:false,
      local!selection,
      local!selectedRow,
      {
        a!sectionLayout(
          label: "",
          contents: {
            a!gridField(
              data: todatasubset(ri!substances_HTTP, fv!pagingInfo),
              columns: {
                a!gridColumn(
                  label: "Chem Type",
                  value: if(
                    find("$",fv!row.chemicalType,1)>1,
                    fv!row.chemicalType,
                    fv!row.chemicalType &"$"
                    )
                ),
                a!gridColumn(
                  label: "Submission Chemical Name",
                  value: fv!row.scientificName
                ),
                a!gridColumn(
                  label: "Submission CAS Number",
                  value: rule!DCC_formatCASNumber(fv!row.registryId)
                )
              },
              selectable: 
              if(
                ri!indexType_text = cons!DCC_LABEL_QC_DOCUMENTS,
                false,
                true
              ),
              selectionValue: local!selection,
              selectionSaveInto: {
                local!selection,
                /* This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEmployees. */
                a!save(
                  local!selectedRow,
                  append(local!selectedRow, fv!selectedRows)
                ),
                /* This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEmployees. */
                a!save(
                  local!selectedRow,
                  difference(local!selectedRow, fv!deselectedRows)
                )
              }
            ),
    
      if(
        ri!indexType_text = cons!DCC_LABEL_QC_DOCUMENTS,
        {},
        a!buttonLayout(
          secondaryButtons: {
            a!buttonWidget(
              label: cons!DCC_BUTTON_SELECT,
              value: cons!DCC_BUTTON_SELECT,
              saveInto: {
                ri!buttonValue_text,
                a!forEach(
                  items: local!selectedRow,
                  expression:
                  if(
                    rule!FARM_isNullOrEmpty(ri!selectedSubstance_HTTP),
                    a!save(
                      ri!selectedSubstance_HTTP,
                      append(
                        ri!selectedSubstance_HTTP,
                        local!selectedRow[fv!index]
                      )
                    ),
                    if(
                      tointeger(
                        length(
                          wherecontains(
                            local!selectedRow[fv!index].substanceId,
                            index(
                              ri!selectedSubstance_HTTP,
                              "substanceId",
                              ""
                            )
                          )
                        )
                      ) = 1,
                      a!save(local!selectedRow[fv!index], null),
                      a!save(
                        ri!selectedSubstance_HTTP,append(
                          ri!selectedSubstance_HTTP,
                          local!selectedRow[fv!index]
                        )
                      )
                    )
                  )
                ),
                
                a!save(local!selectedRow, null),
                a!save(local!selection, null),
               
    
              },
              style: "PRIMARY",
              showWhen: not(
                rule!FARM_isNullOrEmpty(ri!substances_HTTP)
              )
            )
          }
        )
    )
           
          }
        )
      }
    )
    Here is the code for Grid 1

  • Expression uses ri! value which is coming from Grid 1. Can you please help where do I need to specify a!refreshVariable? Grid 1 code is attached in below response

  • 0
    Certified Lead Developer
    in reply to lalithap4822

    You don't. I just wanted to make sure that the issue is not coming from one of the nested expressions.

  • 0
    Certified Lead Developer
    in reply to lalithap4822

    I wrote a blogpost about data flow in interfaces a while ago. That might help you.

    https://appian.rocks/2022/07/05/data-in-interfaces/

    In general, I suggest to invest some research time in a much more simplified version of what you want to do. Once working and fully understood, go back to solving your issue.