regarding grids with form

How can we get in uploaded Document name ,uploaded by and uploaded on in supervisor form using grids of 3 column.

  Discussion posts and replies are publicly visible

Parents
  • Assuming that document is already uploaded, as Stefan notes, you can retrieve those properties using the document() function, such as:

    a!localVariables(
      local!doc: /* Your Document(s) here */,
    
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Document Name"),
          a!gridLayoutHeaderCell(label: "Uploaded By"),
          a!gridLayoutHeaderCell(label: "Uploaded On")
        },
        rows: a!forEach(
          items: local!doc,
          expression: a!gridRowLayout(
            id: fv!index,
            contents: {
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"name")
                )
              ),
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"lastUserToModify")
                )
              ),
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"dateCreated")
                )
              )
            }
          )
        )
      )
    )

  • a!localVariables(

    local!doc:/* your documents here*/

    So here documents in the sense target documents or what?

    So my target documents here cons!name of file.

  • a!formLayout(
    label: "Add Vehicle to Fleet",
    contents: {
    a!columnsLayout(
    columns: {
    a!columnLayout(
    contents: {
    a!textField(
    label: "Vehicle Make",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleMake,
    saveInto: ri!vehicle.vehicleMake,
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleMake
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleMake
    ) & " characters.",
    null
    )
    ),
    a!paragraphField(
    label: "Vehicle Condition",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleCategory,
    saveInto: ri!vehicle.vehicleCategory,
    required: true,
    requiredMessage: "ri!vehicle.mileage > 500",
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleCategory
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleCategory
    ) & " characters.",
    null
    )
    ),
    a!textField(
    label: "Vehicle VIN",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleVIN,
    saveInto: ri!vehicle.vehicleVIN,
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleVIN
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleVIN
    ) & " characters.",
    null
    )
    ),
    a!textField(
    label: "Vehicle Status",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: "Initiated",
    saveInto: ri!vehicle.vehicleStatus,
    showWhen: true,
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleStatus
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleStatus
    ) & " characters.",
    null
    )
    ),
    a!dateField(
    label: "Vehicle Last Modified By",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleLastModifiedBy,
    saveInto: ri!vehicle.vehicleLastModifiedBy,
    readOnly: ri!readOnly
    ),
    a!dateField(
    label: "Vehicle Added By",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleAddedBy,
    saveInto: ri!vehicle.vehicleAddedBy,
    readOnly: ri!readOnly
    ),
    a!columnsLayout(
    columns: {
    a!columnLayout(
    contents: {
    a!fileUploadField(
    label: "vehicle Photos",

    labelPosition: "ABOVE",
    target: cons!SG_vehicle_photos,

    value: ri!vehicle.vehiclePhotos,
    saveInto: ri!vehicle.vehiclePhotos,
    showWhen: if(ri!vehicle.vehicleCategory = cons!SG_VEHICLE_CATEGORIES[2],true(),false()),
    required: true,
    validations: a!localVariables(
    local!invalidExtensions: difference(upper(fv!files.extension), { "PNG", "JPG" ,"JPEG"}),
    if(
    length(local!invalidExtensions) > 0,
    "Attachments must be images. Remove: " &
    index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}),
    ""
    )
    )
    )
    }
    ),
    a!columnLayout(
    contents: {
    a!fileUploadField(
    label: "vehicle insurance number",
    labelPosition: "ABOVE",
    target: cons!SG_Insurance_Document,

    value: ri!vehicle.vehicleInsurancenumber,
    saveInto: ri!vehicle.vehicleInsurancenumber,
    showWhen: if(ri!vehicle.vehicleCategory = cons!SG_VEHICLE_CATEGORIES[2],true(),false()),
    required: true,
    validations: a!localVariables(
    local!invalidExtensions: difference(upper(fv!files.extension), {"PDF"}),
    if(
    length(local!invalidExtensions) > 0,
    "Attachments must be PDF. Remove: " &
    index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}),
    ""
    )
    )

    )
    }
    ),
    a!columnLayout(
    contents: {
    a!fileUploadField(
    label: "vehicle ownersID proof",
    labelPosition: "ABOVE",
    target: cons!SG_ID_PROOF,

    value: ri!vehicle.ownersIDProof,
    saveInto: ri!vehicle.ownersIDProof,
    showWhen: if(ri!vehicle.vehicleCategory = cons!SG_VEHICLE_CATEGORIES[2],true(),false()),
    required: true,
    validations: a!localVariables(
    local!invalidExtensions: difference(upper(fv!files.extension), {"PDF"}),
    if(
    length(local!invalidExtensions) > 0,
    "Attachments must be PDF. Remove: " &
    index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}),
    ""
    )
    )
    )
    }
    )
    }
    ),
    a!dateTimeField(
    label: "Vehicle Last Maintenance Date",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleLastMaintenanceDate,
    saveInto: ri!vehicle.vehicleLastMaintenanceDate,
    readOnly: ri!readOnly
    )
    }
    ),
    a!columnLayout(
    contents: {
    a!textField(
    label: "Vehicle Model",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleModel,
    saveInto: ri!vehicle.vehicleModel,
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleModel
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleModel
    ) & " characters.",
    null
    )
    ),
    a!textField(
    label: "Vehicle Colour",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleColour,
    saveInto: ri!vehicle.vehicleColour,
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleColour
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleColour
    ) & " characters.",
    null
    )
    ),
    a!textField(
    label: "Vehicle Condition",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleCondition,
    saveInto: ri!vehicle.vehicleCondition,
    showWhen: ri!readOnly = true(),
    readOnly: ri!readOnly,
    validations: if(
    len(
    ri!vehicle.vehicleCondition
    ) > 255,
    "Value may not be longer than 255 characters. You have entered " & len(
    ri!vehicle.vehicleCondition
    ) & " characters.",
    null
    )
    ),
    a!integerField(
    label: "Vehicle Year",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleYear,
    saveInto: ri!vehicle.vehicleYear,
    readOnly: ri!readOnly
    ),
    a!integerField(
    label: "Vehicle Mileage",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleMileage,
    saveInto: ri!vehicle.vehicleMileage,
    readOnly: ri!readOnly
    ),
    a!dropdownField(
    label: "Category",
    labelPosition: "ABOVE",
    placeholderLabel: "upload related documents by selecting applicable category",
    choiceLabels: cons!SG_VEHICLE_CATEGORIES,
    choiceValues: cons!SG_VEHICLE_CATEGORIES,
    value: ri!vehicle.vehicleCategory,
    saveInto: ri!vehicle.vehicleCategory,
    showWhen: or(
    isnull(ri!readOnly),
    ri!readOnly=false()
    ),
    validations: {}
    ),
    a!dateField(
    label: "Vehicle Date Added",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleDateAdded,
    saveInto: ri!vehicle.vehicleDateAdded,
    readOnly: ri!readOnly
    ),
    a!dateTimeField(
    label: "Vehicle Next Maintenance Date",
    labelPosition: if(
    ri!readOnly,
    "ADJACENT",
    "ABOVE"
    ),
    value: ri!vehicle.vehicleNextMaintenanceDate,
    saveInto: ri!vehicle.vehicleNextMaintenanceDate,
    readOnly: ri!readOnly
    ),
    a!dateField(
    label: "",
    labelPosition: "ABOVE",
    saveInto: {},
    validations: {}
    ),
    a!dateField(
    label: "vehicleNextServiceDate",
    labelPosition: "ABOVE",
    value: ri!vehicle.vehicleNextServiceDate,
    saveInto: ri!vehicle.vehicleNextServiceDate,
    readOnly: false,
    validations: {}
    )
    }
    )
    }
    ),
    a!sideBySideLayout(
    items: {
    a!sideBySideItem(
    item: a!fileUploadField(
    label: "Rc document",
    labelPosition: "ABOVE",
    instructions: "only PNG or JPEG or JPG format applicable.",
    target: cons!SG_document_folder_pointer,

    value:ri!vehicle.vehicleRCNumber,
    saveInto:ri!vehicle.vehicleRCNumber,
    showWhen: if(ri!vehicle.vehicleCategory=cons!SG_VEHICLE_CATEGORIES[1],true(),false()),

    required: true,
    validations: a!localVariables(
    local!invalidExtensions: difference(upper(fv!files.extension), { "PNG", "JPG" ,"JPEG"}),
    if(
    length(local!invalidExtensions) > 0,
    "Attachments must be images. Remove: " &
    index(fv!files, "name", wherecontains(local!invalidExtensions, upper(fv!files.extension)), {}),
    ""
    )
    )
    )
    )
    }
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Submit",
    value: if(
    isnull(ri!vehicle.vehicleLastModifiedBy), "",
    rule!VFM_CalculateNextServiceDate(
    ri!vehicle.vehicleCategory,
    ri!vehicle.vehicleLastModifiedBy
    )),
    saveInto: {ri!vehicle.vehicleNextServiceDate,
    a!save(ri!vehicle.vehicleLastModifiedBy,now())
    },
    submit: true,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: "Cancel",
    value: true,
    saveInto: ri!cancel,
    submit: true,
    style: "NORMAL",
    validate: false
    )
    },
    showWhen: or(
    isnull(
    ri!readOnly
    ),
    not(
    ri!readOnly
    )
    )
    )
    )

    This is my interface

  • Are you trying to display the details of a document uploaded on this same form?  Otherwise, where are the document(s) located you want to display details for?

    Also, when posting code please try out the Insert -> Code feature for easier readability. 

  • yes I want to display details in the supervisor form.

    1. In the supervisor screen, show the uploaded documents in the grid-
      • Grid should have 3 columns – Document Name, Uploaded On, Uploaded by.
  • I'm still not sure if the code you posted is the Supervisor Form, or if it is the submission form prior to the Supervisor Form.

    As Stefan noted initially here, the form where you are uploading documents must be submitted to turn the upload into a document type object.  You cannot access the upload as a document type on the same form it is being uploaded on.  In the situation where you need to display the document properties on the same form (not sure why you would need to tell the uploader details on what they just uploaded), generally the theory is to submit the form without validations and chain back to itself.

    If the document has already been uploaded, you can use my code above and point to whatever document you want such as ri!vehicle.vehicleRCNumber.

  • yes I can use your code but the thing is uploaded document details is in cons! folder.

    So seems can't I use cons! folder in place of local!doc.

  • Gotcha, correct while you can't point to the folder directly in the code above, you can retrieve the documents that are within the folder using:

    folder(cons!YOUR_FOLDER, "documentChildren")

    Updating my code with the logic to retrieve docs from the folder:

    a!localVariables(
      local!doc: folder(cons!YOUR_FOLDER, "documentChildren"),
    
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Document Name"),
          a!gridLayoutHeaderCell(label: "Uploaded By"),
          a!gridLayoutHeaderCell(label: "Uploaded On")
        },
        rows: a!forEach(
          items: local!doc,
          expression: a!gridRowLayout(
            id: fv!index,
            contents: {
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"name")
                )
              ),
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"lastUserToModify")
                )
              ),
              a!richTextDisplayField(
                value: a!richTextItem(
                  text: document(fv!item,"dateCreated")
                )
              )
            }
          )
        )
      )
    )

  • folder(folderId, property)
    
    Returns a property of the requested folder. The return type will be the type of that property; for example selecting ’dateCreated’ as the property parameter returns a Date and Time value.
    
    Returns: Any Type
    
    folderId (Number (Integer)): The ID of the folder to be retrieved.
    can't use like that.

  • I will submit that, yes you can, until you show me an error message.

    Appian will convert the "folder" type object to it's ID for use within the folder() function automatically.

    I have tested this again successfully with my code locally.  I always suggest trying before assuming.

  • 0
    Certified Lead Developer
    in reply to JS0001

    This is what will happen if you don't use the folder() function correctly.  Please refer back to how Chris used it in his example, in particular the highlighted part:

    The properties you can pass into folder() are strictly defined, you can't just pass in random strings as you've done (i.e. passing in "SG_Document"), and expect it to work.

Reply Children
No Data