editable grid

Hi..my requirement is to delete the uploaded documents ,I am getting added by and adden on values before uploading documents.I have written this code.Can anyone suggest me on this.

a!localVariables(
local!crCustFolder_cdt: rule!CR_CUST_QE_getfolderIdDetailsBasedOnCif(
cif_int: ri!cif_int
),
local!getFolderId_int: index(
local!crCustFolder_cdt,
"folderId_int",
tointeger(null)
),
a!gridLayout(

label: {ri!sectionName_txt & if(ri!sectionName_txt = cons!CR_CUST_SECTION_NAME[1], cons!CR_CUST_GRID_LABEL[1], cons!CR_CUST_GRID_LABEL[2])},
headerCells: {
a!gridLayoutHeaderCell(
label:cons!CR_APP_DOCUMENTS[1],
),
a!gridLayoutHeaderCell(
label:cons!CR_APP_DOCUMENTS[2],
),
a!gridLayoutHeaderCell(
label:cons!CR_APP_DOCUMENTS[3],
),
a!gridLayoutHeaderCell(
label:cons!CR_APP_DOCUMENTS[4],
),

a!gridLayoutHeaderCell(
label:"",
)
},
columnConfigs: {
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: "1"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: "1"
),
a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: "1"
),

a!gridLayoutColumnConfig(
width: "DISTRIBUTE",
weight: "1"
),
/*a!gridLayoutColumnConfig(*/
/*width: "DISTRIBUTE",*/
/*weight: "1"*/
/*),*/
a!gridLayoutColumnConfig(
width: "ICON"
)
},

rows: a!forEach(
items: ri!crCustDoc_cdt,
expression: a!gridRowLayout(
id:fv!item.id_int,
contents: {
a!textField(
label:"",
value: index(
fv!item,
"docDesc_txt",
""
)
/*value: a!linkField(*/
/*label: if(isnull(fv!item.docId_int),"",*/
/*document(fv!item.docId_int, "name")),*/
/*links: a!documentDownloadLink(*/
/*label: if(isnull(fv!item.docId_int),"",*/
/*document(fv!item.docId_int, "name")),*/
/*document: fv!item.docId_int*/
/*)*/
/*)*/
),


a!textField(
value: rule!APN_FN_getDisplayName(
userId: index(
fv!item,
"addedBy_txt",
{}
)
),
readOnly: true(),

),
a!textField(
value: rule!CR_FN_nbfDateTimeFormat(
input: fv!item.addedOn_dt
),
readOnly: true(),

),

a!fileUploadField(
label: "File Upload",
labelPosition: "ABOVE",
target: tofolder(
ri!folderId_int
),
value: ri!uploadedDoc_int,
/*value: index(*/
/*fv!item,*/
/*"docId_int",*/
/*""*/
/*),*/
saveInto: ri!uploadedDoc_int,
/*saveInto: {*/
/*fv!item.docId_int,*/
/*if(*/
/*rule!APN_isBlank(*/
/*fv!item.docId_int*/
/*),*/
/*{},*/
/*a!save(*/
/*fv!item,*/
/*updatedictionary(*/
/*dictionary: fv!item,*/
/*fieldsAndValues: {*/
/*updatedOn_dt: now(),*/
/*docUploadedOn_dt: now(),*/
/*updatedBy_txt: loggedInUser(),*/
/*updatedByRole_txt: rule!CR_FN_getUserRole(*/
/*inputUser_txt: loggedInUser()*/
/*)*/
/*}*/
/*)*/
/*)*/
/*)*/
/*},*/

required: true(),
showWhen: if(
ri!IsReadOnly_boolean,
false(),
true()
),
validations: {
a!localVariables(
local!invalidExtensions: difference(
upper(
fv!files.extension
),
{
cons!CR_CUST_FILE_EXTENSION
}
),
if(
length(
local!invalidExtensions
) > 0,
cons!CR_CUST_VALIDATION_MESSAGE[1] & index(
fv!files,
"name",
wherecontains(
local!invalidExtensions,
upper(
fv!files.extension
)
),
{}
),
""
)
),
if(
or(
fv!files.size > cons!CR_CUST_MAX_UPLOAD_FILE_SIZE
),
cons!CR_CUST_VALIDATION_MESSAGE[2] & index(
fv!files,
"name",
where(
fv!files.size > cons!CR_CUST_MAX_UPLOAD_FILE_SIZE
),
{}
),
""
)

},
maxSelections:1,
),

a!richTextDisplayField(
label: "Remove",
value: a!richTextIcon(
linkStyle: "STANDALONE",
color: "NEGATIVE",
icon: "REMOVE",
caption: "Delete",
link: a!dynamicLink(
value: cons!CR_APP_TXT_AUDIT_STATUS[3],

),

)
)

}
)
),
addRowLink: a!dynamicLink(
label: "Add Documents",
value: true(),
saveInto: {
a!save(
ri!crCustDoc_cdt,
append(
ri!crCustDoc_cdt,
'type!{urn:com:appian:types:NBF}CR_Cust_Doc'(
cif_int: ri!cif_int,
folderId_int:ri!folderId_int ,
addedByRole_txt: rule!CR_FN_getUserRole(
inputUser_txt: loggedInUser()
),
addedOn_dt: now(),
addedBy_txt: loggedInUser()
/*requestId_int: ri!requestId_int,*/
/*cif_int: ri!cif_int,*/
/*docType_txt: "",*/
/*collateralDocRefId_int: - 999,*/
/*docRequiredFlag_txt: cons!CR_TXT_CHOICE_LABELS_YES_NO[1],*/
/*docProvidedFlag_txt: cons!CR_TXT_CHOICE_LABELS_YES_NO[2],*/
/*folderId_int: ri!folderId_int,*/
/*rowStatus_txt: cons!CR_APP_TXT_AUDIT_STATUS[1],*/
/*legacyStatus_txt: cons!CR_APP_TXT_AUDIT_STATUS[1],*/
/*isLocked_int: 0,*/
/*isPartiallyLocked_int: 0,*/
/*addedByRole_txt: rule!CR_FN_getUserRole(*/
/*inputUser_txt: loggedInUser()*/
/*),*/
/*addedOn_dt: now(),*/
/*addedBy_txt: loggedInUser()*/
)
)
)
},
/*showWhen: if(*/
/*ri!IsReadOnly_boolean,*/
/*false(),*/
/*true()*/
/*)*/
),
)
)

  Discussion posts and replies are publicly visible

Parents Reply Children
  • a!localVariables(
      local!crCustFolder_cdt: rule!CR_CUST_QE_getfolderIdDetailsBasedOnCif(
        cif_int: ri!cif_int
      ),
      local!getFolderId_int: index(
        local!crCustFolder_cdt,
        "folderId_int",
        tointeger(null)
      ),
      a!gridLayout(
    
        label: {ri!sectionName_txt & if(ri!sectionName_txt = cons!CR_CUST_SECTION_NAME[1], cons!CR_CUST_GRID_LABEL[1], cons!CR_CUST_GRID_LABEL[2])},
        headerCells: {
          a!gridLayoutHeaderCell(
            label:cons!CR_APP_DOCUMENTS[1]
          ),
          a!gridLayoutHeaderCell(
            label:cons!CR_APP_DOCUMENTS[2]
          ),
          a!gridLayoutHeaderCell(
            label:cons!CR_APP_DOCUMENTS[3]
          ),
          a!gridLayoutHeaderCell(
            label:cons!CR_APP_DOCUMENTS[4]
          ),
          
          a!gridLayoutHeaderCell(
            label:""
          )
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: "1"
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: "1"
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: "1"
          ),
          
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: "1"
          ),
          
          a!gridLayoutColumnConfig(
            width: "ICON"
          )
        },
    
        rows: a!forEach(
          items: ri!crCustDoc_cdt,
          expression: a!gridRowLayout(
            id:fv!item.id_int,
            contents: {
              a!textField(
                label:"",
               
                /*value: a!linkField(*/
                  /*label: if(isnull(fv!item.docId_int),"",*/
                  /*document(fv!item.docId_int, "name")),*/
                  /*links: a!documentDownloadLink(*/
                    /*label: if(isnull(fv!item.docId_int),"",*/
                    /*document(fv!item.docId_int, "name")),*/
                    /*document: fv!item.docId_int*/
                  /*)*/
                /*)*/
              ),
             
             
              a!textField(
                value: rule!APN_FN_getDisplayName(
                  userId: index(
                    fv!item,
                    "addedBy_txt",
                    {}
                  )
                ),
                readOnly: true()
               
              ),
              a!textField(
                value: rule!CR_FN_nbfDateTimeFormat(
                  input: fv!item.addedOn_dt
                ),
                readOnly: true()
                
               
              ),
              
              a!fileUploadField(
                label: "File Upload",
                labelPosition: "ABOVE",
                target: tofolder(
                  ri!folderId_int
                ),
                maxSelections:1,
                value: ri!uploadedDoc_int,
                
                saveInto: ri!uploadedDoc_int,
                showWhen: if(
                  ri!IsReadOnly_boolean,
                  false(),
                  true()
                ),
               
               
                required: true(),
                validations: {
                  a!localVariables(
                    local!invalidExtensions: difference(
                      upper(
                        fv!files.extension
                      ),
                      {
                        cons!CR_CUST_FILE_EXTENSION
                      }
                    ),
                    if(
                      length(
                        local!invalidExtensions
                      ) > 0,
                      cons!CR_CUST_VALIDATION_MESSAGE[1] & index(
                        fv!files,
                        "name",
                        wherecontains(
                          local!invalidExtensions,
                          upper(
                            fv!files.extension
                          )
                        ),
                        {}
                      ),
                      ""
                    )
                  ),
                  if(
                    or(
                      fv!files.size > cons!CR_CUST_MAX_UPLOAD_FILE_SIZE
                    ),
                    cons!CR_CUST_VALIDATION_MESSAGE[2] & index(
                      fv!files,
                      "name",
                      where(
                        fv!files.size > cons!CR_CUST_MAX_UPLOAD_FILE_SIZE
                      ),
                      {}
                    ),
                    ""
                  )
                  
                }
              ),
              
              a!richTextDisplayField(
                label: "Remove",
                value: a!richTextIcon(
                  icon: "REMOVE",
                  caption: "Delete",
                  link: a!dynamicLink(
                    value: cons!CR_APP_TXT_AUDIT_STATUS[3]
    
                  ),
                  linkStyle: "STANDALONE",
                  color: "NEGATIVE"
    
                )
              )
    
            }
          )  
        ),
        addRowLink: a!dynamicLink(
          label: "Add Documents",
          value: true(),
          saveInto: {
            a!save(
              ri!crCustDoc_cdt,
              append(
                ri!crCustDoc_cdt,
                'type!{urn:com:appian:types:NBF}CR_Cust_Doc'(
                  cif_int: ri!cif_int,
                  folderId_int:ri!folderId_int ,
                  
                  
                )
              )
            )
          }
          
        )
      )
    )

  • 0
    Certified Lead Developer
    in reply to JS0001

    Way better.

    What exactly to you mean with "delete the uploaded documents ,I am getting added by and adden on values before uploading documents"?

  • Yeah I think it would be helpful to describe what your goal is here. Some things I did notice in the code are that your delete icon doesn't currently do anything (there's no saveInto), and your added by and added columns are always read only, so your current code doesn't provide any way of editing them.