Want to preload editable grid having Dropdown values with file upload .

Actually I am having editable grid which is shown below .. contains components  dropdown and  file upload field and Text Field 

I want to preload the required values of dropdown , when user opens the page he should see the grid with selected dropdown values. as shown below 

all other functionality of grid will work as it is .. like removing adding new row .. 

please find the code-snipet attached (in the snipet Local!required Documents .. is just an id label we are storing in lookupref Table  so we can get from there)

  local!selectedDocuments: if(
    a!isNullOrEmpty(local!data),
    {
      'recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents'()
    },
    local!data
  ),
  
  local!requiredDocuments:{198,199,191,193},




a!gridLayout(
          label: "",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Document Type"),
            a!gridLayoutHeaderCell(label: "Document"),
            a!gridLayoutHeaderCell(label: "Description"),
            a!gridLayoutHeaderCell(label: "Remove")
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(),
            a!gridLayoutColumnConfig(),
            a!gridLayoutColumnConfig(),
            a!gridLayoutColumnConfig(width: "ICON")
          },
          rows: {
            a!forEach(
              items: local!selectedDocuments,
              expression: a!gridRowLayout(
                contents: {
                  a!dropdownField(
                    placeholder: "Select Document Type",
                    choiceLabels: if(
                      local!documentType,
                      property(
                        local!choicevalues,
                        'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{9b08548e-5e40-41e6-a600-39e36f53bd2d}label',
                        {}
                      ),
                      property(
                        local!documentLookupValues,
                        'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{9b08548e-5e40-41e6-a600-39e36f53bd2d}label',
                        {}
                      )
                    ),
                    choiceValues: if(
                      local!documentType,
                      property(
                        local!choicevalues,
                        'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{90e98305-1db5-4c60-94f2-766a530e0dd3}lookupRefId',
                        {}
                      ),
                      property(
                        local!documentLookupValues,
                        'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{90e98305-1db5-4c60-94f2-766a530e0dd3}lookupRefId',
                        {}
                      )
                    ),
                    value: if(
                      a!isNullOrEmpty(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId']
                      ),
                      local!documentLookupRefIds,
                      fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId']
                    ),
                    saveInto: {
                      a!save(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId'],
                        save!value
                      ),
                      a!save(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{1056ba0c-3a49-4e35-80f4-a8be3e97890c}documentName'],
                        rule!OCO_findCDTbyAnyField(
                          cdts: local!documentLookupValues,
                          where: 'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{90e98305-1db5-4c60-94f2-766a530e0dd3}lookupRefId',
                          equals: save!value,
                          select: 'recordType!{678c67a1-267c-432d-81f9-7d90a0e6925e}PRO Lookup.fields.{9b08548e-5e40-41e6-a600-39e36f53bd2d}label'
                        )
                      ),
                      if(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId'] = cons!PRO_LEAD_DOCUMENT_TYPE_OPERATING_OR_STATE_LICENSE,
                        {
                          a!save(
                            local!countOSL,
                            tointeger(sum(1, local!countOSL))
                          )
                        },
                        {}
                      ),
                      if(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId'] = cons!PRO_LEAD_DOCUMENT_TYPE_CERTIFICATE_OF_GENERAL_AND_PROFESSIONAL,
                        {
                          a!save(
                            local!countCOG,
                            tointeger(sum(1, local!countCOG))
                          )
                        },
                        {}
                      ),
                      if(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId'] = cons!PRO_LEAD_DOCUMENT_TYPE_CERTIFICATE_OF_ACCREDITIATION,
                        {
                          a!save(
                            local!countCOA,
                            tointeger(sum(1, local!countCOA))
                          )
                        },
                        {}
                      ),
                      a!save(
                        ri!countOperatingLicense,
                        local!countOSL
                      ),
                      a!save(ri!countCertificate, local!countCOG),
                      a!save(
                        ri!countCertificateOfAccrediation,
                        local!countCOA
                      ),
                      a!save(
                        ri!requiredDocuments,
                        local!requiredDocuments
                      )
                    },
                    searchDisplay: "AUTO",
                    required: true
                  ),
                  a!fileUploadField(
                    label: "",
                    labelPosition: "COLLAPSED",
                    target: a!defaultValue(
                      local!folder,
                      cons!PRO_FOLDER_LEAD_DOCUMENTS_ATTACHMENTS
                    ),
                    maxSelections: 1,
                    value: if(
                      a!isNullOrEmpty(fv!item),
                      "",
                      fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{42dfb404-4221-4f95-ba73-314e2f21a0b7}documentId']
                    ),
                    saveInto: if(
                      a!isNotNullOrEmpty(
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{30b4e4c0-70b2-4a92-9731-e37a96666060}leadDocumentId']
                      ),
                      {
                        a!save(
                          ri!deletedDocuments,
                          append(
                            ri!deletedDocuments,
                            todocument(
                              fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{42dfb404-4221-4f95-ba73-314e2f21a0b7}documentId']
                            )
                          )
                        ),
                        fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{42dfb404-4221-4f95-ba73-314e2f21a0b7}documentId']
                      },
                      fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{42dfb404-4221-4f95-ba73-314e2f21a0b7}documentId']
                    ),
                    required: true,
                    validations: if(
                      or(
                        tointeger(
                          fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId']
                        ) = cons!PRO_LEAD_DOCUMENT_TYPE_W9_FORM,
                        tointeger(
                          fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{5312c731-e8d4-4eed-87e1-0447536d6e4d}leadDocumentLookupRefId']
                        ) = cons!PRO_LEAD_DOCUMENT_TYPE_CONTRACT
                      ),
                      {
                        if(
                          contains("pdf", fv!files.extension),
                          "",
                          "Invalid Format"
                        )
                      },
                      if(
                        or(
                          contains("pdf", fv!files.extension),
                          contains("csv", fv!files.extension),
                          contains("xlsx", fv!files.extension)
                        ),
                        "",
                        "Invalid Format"
                      )
                    ),
                    uploadMethods: "CHOOSE_FILE",
                    buttonDisplay: "LABEL_AND_ICON",
                    buttonStyle: "STANDARD"
                  ),
                  a!textField(
                    label: "Description",
                    value: if(
                      a!isNullOrEmpty(fv!item),
                      "",
                      fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{897b83c7-cce0-4792-bd3f-ecdee384ad72}description']
                    ),
                    saveInto: fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{897b83c7-cce0-4792-bd3f-ecdee384ad72}description']
                  ),
                  a!richTextDisplayField(
                    value: a!richTextIcon(
                      icon: "times-circle-o",
                      altText: "delete",
                      caption: "Remove",
                      link: a!dynamicLink(
                        value: fv!item,
                        saveInto: {
                          a!save(
                            ri!deletedDocuments,
                            append(
                              ri!deletedDocuments,
                              todocument(
                                fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{42dfb404-4221-4f95-ba73-314e2f21a0b7}documentId']
                              )
                            )
                          ),
                          if(
                            contains(local!data, fv!item),
                            a!save(
                              ri!deletedDocumentIds,
                              append(
                                ri!deletedDocumentIds,
                                fv!item['recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents.fields.{30b4e4c0-70b2-4a92-9731-e37a96666060}leadDocumentId']
                              )
                            ),
                            {}
                          ),
                          a!save(
                            local!selectedDocuments,
                            remove(local!selectedDocuments, fv!index)
                          )
                        }
                      ),
                      linkStyle: "STANDALONE",
                      color: "NEGATIVE"
                    ),
                    align: "CENTER"
                  )
                }
              )
            )
          },
          selectionSaveInto: {},
          addRowlink: a!dynamicLink(
            label: "Add Document",
            saveInto: {
              a!save(
                local!selectedDocuments,
                append(
                  local!selectedDocuments,
                  'recordType!{e5935b72-2349-43df-bd15-908d316468be}PRO Lead Documents'()
                )
              )
            }
          ),
          validations: {},
          shadeAlternateRows: true,
          spacing: "DENSE"
        )

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Not sure in which context this is done.

    You can pre-populate it in the process before passing as an input to the form as described here: docs.appian.com/.../recipe-set-the-default-value-of-an-input-on-a-task-form.html

    Otherwise, if you want something self-contained, you basically load the rule input in a local, set the values with a!update and then save the local back into the rule input when the user submits the form.

    a!localVariables(
      local!entity: a!update(ri!entity, "preloadedField", "value1"),
      {
        a!textField(value: local!entity.preloadedField),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Submit",
              saveInto: { a!save(ri!entity, local!entity) }
            )
          }
        )
      }
    )

  • HI Klaus34

    if you want to pre upload the data, u can store the data in the locals and the pass the locals to the grid. 

    Please find the below attached code for the reference.

    a!localVariables(
      local!data: {
        a!map(
          id : 1,
          dropDownValue: "Value 1",
          fileUploadValue: null
        ),
        a!map(
          id : 2,
          dropDownValue: "Value 2",
          fileUploadValue: null
        )
      },
      {
        a!gridLayout(
          headerCells: {
            a!gridLayoutHeaderCell(
              label: "Drop Down"
            ),
            a!gridLayoutHeaderCell(
              label: "File Upload"
            ),
            a!gridLayoutHeaderCell(
              label: "Remove"
            )
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE"
            ),
            a!gridLayoutColumnConfig(
              width: "DISTRIBUTE"
            ),
            a!gridLayoutColumnConfig(
              width: "ICON"
            )
          },
          rows: {
            a!forEach(
              items: local!data,
              expression: {
                a!gridRowLayout(
                  contents: {
                    a!textField(
                      value: fv!item.dropDownValue
                    ),
                    a!fileUploadField(
                      value: fv!item.fileUploadValue
                    ),
                    a!richTextDisplayField(
                      labelPosition: "COLLAPSED",
                      value: {
                        a!richTextIcon(
                          icon: "times",
                          linkStyle: "STANDALONE",
                          link: a!dynamicLink(
                            saveInto: {
                              a!save(
                                local!data,remove(local!data,fv!index)
                              )
                            }
                          )
                        )
                      }
                    )
                  }
                )
              }
            )
          }
        )
      }
    )

    Thanks