How to export a read only grid in Excel?

Certified Associate Developer

Hi,

my problem is that I can export correctly the entity and download as Excel file but when I open the file only appear the data of father CDT but not the rest of the nested CDT.

This is the code of my grid:

a!localVariables(  
  local!autoridad:null,
  /*local!selectedAudiencia: ri!audiencia,*/
  local!startIndex: a!refreshVariable(
    value: 1,
    refreshOnVarChange: {ri!selection,ri!autoridad, ri!motivo, ri!empleo, ri!ejercito, ri!situacion, ri!audiencia}
  ),
  local!pageSize: 10,
  local!sort: {
    a!sortInfo(
      field: "id",
      ascending: false()
    )
  },
  local!pagingInfo: a!pagingInfo(
    startIndex: local!startIndex,
    batchSize: local!pageSize,
    sort: local!sort
  ),
  local!selection: ri!selection,
  local!data: a!refreshVariable(
    value: rule!AU_ER_getAudienciasByFilter(
      autoridad: ri!autoridad,
      motivo:  ri!motivo,
      empleo: ri!empleo,
      ejercito: ri!ejercito,
      situacion: ri!situacion,
      nombre: ri!nombre,
      pagingInfo: local!pagingInfo),
    refreshAlways: true,
    refreshInterval: 0.5,
    refreshOnVarChange: local!selection
  ),
  a!gridField(    
    data: local!data,    
    columns: {
      /*a!gridColumn(
        label: "ID",
        sortField: "id",
        value:index(fv!row, "id", null)
      ),*/
      a!gridColumn(
        label: "",
        value: a!richTextDisplayField(
          value: 
          a!richTextItem(
            text: a!richTextIcon(icon: "search"),
            link: a!startProcessLink(
              label: "",
              processModel: cons!AU_PM_ACTUALIZAR_SOLICITUD,
              processParameters: {
                selection: index(fv!row, "id", null),
                readOnly: true()
              }
            )
          )
        )
      ),
      a!gridColumn(
        label: "",
        value: a!richTextDisplayField(
          value: 
          a!richTextItem(
            text: a!richTextIcon(icon: "pencil-square-o"),
            link: a!startProcessLink(
              label: "",
              processModel: cons!AU_PM_ACTUALIZAR_SOLICITUD,
              processParameters: {
                selection: index(fv!row, "id", null),
                readOnly: 
                if(
                  or(
                    index(index(fv!row, "situacionId", null),"descripcion", null)="CANCELADA",
                    index(index(fv!row, "situacionId", null),"descripcion", null)="DENEGADA"),
                  true(), false())
              }
            )
          )
        )
      ),
      a!gridColumn(
        label: "Nombre",
        sortField: "nombre",
        value:index(fv!row, "nombre", null)
      ),
      a!gridColumn(
        label: "Apellidos",
        sortField: "apellidos",
        value:index(fv!row, "apellidos", null)
      ),
      a!gridColumn(
        label: "Teléfono",
        sortField: "telefono",
        value:index(fv!row, "telefono", null)
      ),
      a!gridColumn(
        label: "Correo electrónico",
        sortField: "email",
        value:index(fv!row, "email", null)
      ),
      a!gridColumn(
        label: "Dirtelex",
        sortField: "dirtelex",
        value:index(fv!row, "dirtelex", null)
      ),
      a!gridColumn(
        label: "Pa",
        sortField: "pa",
        value:index(fv!row, "pa", null)
      ),
      a!gridColumn(
        label: "Autoridad",
        sortField: "autoridadId",
        value:index(index(fv!row, "autoridadId", null),"descripcion", null)
      ),
      a!gridColumn(
        label: "Empleo",
        sortField: "empleoId",
        value:index(index(fv!row, "empleoId", null),"descripcion", null)
      ),
      a!gridColumn(
        label: "Ejército",
        sortField: "ejercitoId",
        value:index(index(fv!row, "ejercitoId", null),"descripcion", null)
      ),
      a!gridColumn(
        label: "Cuerpo",
        sortField: "cuerpo",
        value:index(fv!row, "cuerpo", null)
        ),
        a!gridColumn(
          label: "Archivado",
          sortField: "archivado",
          value:index(fv!row, "archivado", null)
        ),
      a!gridColumn(
        label: "Motivo audiencia",
        sortField: "motivoId",
        value:index(index(fv!row, "motivoId", null),"descripcion", null)
      ),
      
      a!gridColumn(
        label: "Fecha y hora audiencia",
        sortField: "fechaAudiencia",
        value:index(fv!row, "fechaAudiencia", null)
      ),
      
      a!gridColumn(
        label: "Fecha resolución",
        sortField: "fechaResolucion",
        value:index(fv!row, "fechaResolucion", null)
      ),

      a!gridColumn(
        label: "Situación",
        sortField: "situacionId.descripcion",
        value:index(index(fv!row, "situacionId", null),"descripcion", null)
      )

    },    
    pagingSaveInto: {
      a!save(local!startIndex,fv!pagingInfo.startIndex),
      a!save(local!sort, fv!pagingInfo.sort)
    },
    selectable: true,
    selectionstyle: "ROW_HIGHLIGHT"
  )
)

And this is the code of my interface filters with the export button:

a!localVariables(
  local!exportDocId,
  local!errorMessage,
  local!motivo: cast(
    'type!{urn:com:appian:types:AU}AU_MOTIVO?list',
    rule!AU_ER_getAllMotivo()
  ),
  local!empleo: cast(
    'type!{urn:com:appian:types:AU}AU_EMPLEO?list',
    rule!AU_ER_getAllEmpleo()
  ),
  local!ejercito: cast(
    'type!{urn:com:appian:types:AU}AU_EJERCITO?list',
    rule!AU_ER_getAllEjercito()
  ),
  local!autoridad: cast(
    'type!{urn:com:appian:types:AU}AU_AUTORIDAD?list',
    rule!AU_ER_getAllAutoridad()
  ),
  local!situacion: cast(
    'type!{urn:com:appian:types:AU}AU_SITUACION?list',
    rule!AU_ER_getAllSituacion()),
        {
          a!columnsLayout(
            columns: {
              /* Nombre */
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Nombre",
                    placeholder: "Nombre solicitante",
                    value: ri!nombre,
                    saveInto: ri!nombre,
                    refreshAfter: "KEYPRESS",
                    disabled: false(),
                    validations: {}
                  )
                },
                width: "NARROW"
              ),
              /* Autoridad */
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "Autoridad",
                    labelPosition: "ABOVE",
                    placeholder: "--- Seleccione autoridad ---",
                    choiceLabels: local!autoridad.descripcion,
                    choiceValues: local!autoridad.id,
                    value: ri!autoridad.id,
                    saveInto: ri!autoridad.id,
                    searchDisplay: "AUTO",
                    validations: {}
                  )
                },
                width: "NARROW"
              ),
              /* Motivo*/
              if(
                ri!justified_bool,
                {},
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Motivo audiencia",
                      labelPosition: "ABOVE",
                      placeholder: "--- Seleccione motivo ---",
                      choiceLabels: local!motivo.descripcion,
                      choiceValues: local!motivo.id,
                      value: ri!motivo.id,
                      saveInto: ri!motivo.id,
                      searchDisplay: "AUTO",
                      validations: {}
                    )
                  },
                  width: "NARROW"
                )
              ),
              /* Empleo*/        
              if(
                ri!justified_bool,
                {},
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Empleo",
                      labelPosition: "ABOVE",
                      placeholder: "--- Seleccione empleo ---",
                      choiceLabels: local!empleo.descripcion,
                      choiceValues: local!empleo.id,
                      value: ri!empleo.id,
                      saveInto: ri!empleo.id,
                      searchDisplay: "AUTO",
                      validations: {}
                    )
                  },
                  width: "NARROW"
                )
              ),
              /* Ejército*/        
              if(
                ri!justified_bool,
                {},
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Ejército",
                      labelPosition: "ABOVE",
                      placeholder: "--- Seleccione ejército ---",
                      choiceLabels: local!ejercito.descripcion,
                      choiceValues: local!ejercito.id,
                      value: ri!ejercito.id,
                      saveInto: ri!ejercito.id,
                      searchDisplay: "AUTO",
                      validations: {}
                    )
                  },
                  width: "NARROW"
                )
              ),
              if(
                ri!justified_bool,
                {},
                a!columnLayout(
                  contents: {
                    a!dropdownField(
                      label: "Situación",
                      labelPosition: "ABOVE",
                      placeholder: "--- Seleccione situación ---",
                      choiceLabels: local!situacion.descripcion,
                      choiceValues: local!situacion.id,
                      value: ri!situacion.id,
                      saveInto: ri!situacion.id,
                      searchDisplay: "AUTO",
                      validations: {}
                    )
                  },
                  width: "NARROW"
                )
              ),
                a!columnLayout(
                  contents: {
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: /*item: if(*/
                          /*isnull(local!exportDocId),*/
                          /*This link field contains the link that starts the export*/
                          a!richTextDisplayField(
                            label: "",
                            labelPosition: "ABOVE",
                            value: a!richTextItem(
                              text: a!richTextIcon(icon: "file-export", size: "LARGE"),
                              link: a!dynamicLink(
                                label: "Exportar archivo Excel",
                                saveInto: {
                                  a!exportDataStoreEntityToExcel(
                                    entity: cons!AU_AudienciaDT_POINTER,
                                    filters: a!queryLogicalExpression(
                                      operator: "AND",
                                      filters: {
                                        a!queryFilter(
                                          field: "autoridadId.id",
                                          operator: "=",
                                          value:ri!autoridad.id,
                                          applyWhen: not(isnull(ri!autoridad.id))
                                        ),
                                        a!queryFilter(
                                          field: "motivoId.id",
                                          operator: "=",
                                          value:ri!motivo.id,
                                          applyWhen: not(isnull(ri!motivo.id))
                                        ),                                                                            
                                        a!queryFilter(
                                          field: "empleoId",
                                          operator: "=",
                                          value:ri!empleo.id,
                                          applyWhen: not(isnull(ri!empleo.id))
                                        ),                                                                        
                                        a!queryFilter(
                                          field: "situacionId.id",
                                          operator: "=",
                                          value:ri!situacion.id,
                                          applyWhen: not(isnull(ri!situacion.id))
                                        ),                                                                                
                                        a!queryFilter(
                                          field: "nombre",
                                          operator: "includes",
                                          value:ri!nombre,
                                          applyWhen: not(isnull(ri!nombre))
                                        ),
                                        a!queryFilter(
                                          field: "ejercitoId.id",
                                          operator: "=",
                                          value:ri!ejercito.id,
                                          applyWhen: not(isnull(ri!ejercito.id))
                                        )
                                      }
                                    ),
                                    documentName: "Informe " & now(),
                                    saveInFolder: cons!AU_FOLDER_EXCEL,
                                    onSuccess: a!save(
                                      local!exportDocId,
                                      fv!newDocument
                                    ),
                                    /*This displays an error if there is an issue executing the save*/
                                    onError: a!save(
                                      local!errorMessage,
                                      "Error al exportar archivo a Excel"
                                    )
                                  )
                                }
                              ),
                              size: "SMALL"
                            ),
                            align: "RIGHT",
                            marginAbove: "NONE")
                            /*{}*/
                            /*)*/,
                          width: "MINIMIZE"
                        ),
                        a!sideBySideItem(
                          item: if(
                            /*This only displays the download link if a valid document was created*/
                            not(isnull(local!exportDocId)),
                            /*This changes the link to a download link for the newly created document */
                            /*a!linkField(*/
                            /*links: a!documentDownloadLink(*/
                            /*label: "Listo para descargar",*/
                            /*document: local!exportDocId*/
                            /*)*/
                            /*),*/
                            /*a!textField(*/
                            /*value: local!errorMessage,*/
                            /*readOnly: true*/
                            /*)*/
                            a!richTextDisplayField(
                              label: "",
                              labelPosition: "ABOVE",
                              value: a!richTextItem(
                                text: a!richTextIcon(
                                  icon: "download",
                                  link: a!documentDownloadLink(
                                    label: "Listo para descargar",
                                    document: local!exportDocId
                                  ),                                                                                                                       
                                  size: "LARGE"
                                )),
                                align: "RIGHT"),
                                a!textField(
                                  value: local!errorMessage,
                                  readOnly: true
                                )
                          ),
                          width: "MINIMIZE"
                        )
                      },
                      alignVertical: "TOP",
                      spacing: "SPARSE"
                    )
                  },
                  width: "EXTRA_NARROW"
                ),
                a!columnLayout(
                  contents: {},
                  width: "EXTRA_NARROW"
                ),
              a!columnLayout(
                contents: {
                  a!sideBySideLayout(
                    items: {
                      a!sideBySideItem(
                        item: a!buttonArrayLayout(
                          buttons: {
                            a!buttonWidget(
                              label: "",
                              icon: "refresh",
                              saveInto: {
                                if(isnull(ri!selection), a!save( ri!selection, "0"), a!save( ri!selection, null()))            
                              },
                              size: "SMALL",
                              style: "SECONDARY"
                            ),
                            a!buttonWidget(
                              label: "Limpiar Filtros",
                              value: null,
                              saveInto: {
                                if(isnull(ri!selection), a!save( ri!selection, "0"), a!save( ri!selection, null())),
                                ri!autoridad,
                                ri!motivo,                                                                                                                                                                                            
                                ri!situacion,
                                ri!empleo,
                                ri!ejercito,
                                ri!audiencia,
                                ri!nombre,
                                ri!fechaResolucion,
                                local!exportDocId
                              },
                              size: "SMALL",
                              style: "LINK"
                            )
                          },
                          align: "END"
                        )
                      )
                    }
                  )
                }
              )
            }
          ),
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {}
              ),
              a!columnLayout(
                contents: {}
              ),
              a!columnLayout(
                contents: {}
              )
            }
          )
        }
)

Thanks for your help.

  Discussion posts and replies are publicly visible

Parents Reply Children