Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

How to upload a file from a form and save to database

Certified Senior Developer

 I want to upload the file and save it into the database in integer form. How can I do it?

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Sameer Mohsin

    well as i mentioned in my earlier comment (from last month), if you need resolution on this then you'll need to provide a bit more detail on what you're trying, the configuration of your variables / rule inputs / data structure, and your current form code.  And also, you'll need to clarify on what you mean by "only gets the first one selected" - that doesn't really sound like any behavior of the file upload field i'm familiar with.

Children
  • Alright Mike I'm sharing the code of what I have achieved after tweaking the code but i want to ask is that how i can use local variable array and save it in ri!userRequest['recordType!{P_XYZ_REQUEST.fields.requesteddoc'] as this ri variable will take docs id as created in the db. Here's the code I have done.:

    a!localVariables(
    local!Category: rule!P_XYZ_GetRefData(type: "Category"),
    local!docsList: {},

    a!formLayout(
    label: "COMPLAIN FORM",
    contents: {
    a!sectionLayout(
    contents: {
    a!textField(
    label: "USER",
    labelPosition: "ADJACENT",
    value: ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{e6bc3159-2b12-4556-96c0-217891fd587b}useremail'],
    saveInto: a!save(
    ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{e6bc3159-2b12-4556-96c0-217891fd587b}useremail'],save!value
    ),
    refreshAfter: "UNFOCUS",
    required: true,
    readOnly: false,
    validations: {}
    )
    }
    ),
    a!dropdownField(
    label: "REQUEST TYPE",
    labelPosition: "ADJACENT",
    placeholder: "--- Select a Value ---",
    choiceLabels: local!Category['recordType!{f93bce3c-939a-4166-b96d-cb53ddd97f92}P_XYZ_REQCATEGORY.fields.{fcb692d4-c87f-4b65-a963-d1e66b232374}label'],
    choiceValues: local!Category['recordType!{f93bce3c-939a-4166-b96d-cb53ddd97f92}P_XYZ_REQCATEGORY.fields.{cc69a98c-f324-4465-9e0f-b00e48a727be}id'],
    value: ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{329875ac-5ae7-405d-bcd1-c24e26b2d287}requesttype'],
    SaveInto: a!save(
    ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{329875ac-5ae7-405d-bcd1-c24e26b2d287}requesttype'],save!value
    ),
    searchDisplay: "AUTO",
    required: true,
    validations: {}
    ),
    a!paragraphField(
    label: "DESCRIPTION",
    labelPosition: "ADJACENT",
    value: ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription'],
    saveInto: /*ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription']*/
    a!save(
    ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription'],save!value
    ),
    refreshAfter: "UNFOCUS",
    height: "MEDIUM",
    required: true,
    validations: {}
    ),
    a!fileUploadField(
    label: "UPLOAD FILE",
    maxSelections: 10,
    labelPosition: "ADJACENT",
    target: cons!P_XYZ_POINTS_TO_DOCS_FOLDER,
    value: local!docsList,
    saveInto: local!docsList,
    validations: {}
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Submit",
    saveInto: a!save(
    ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{f415d352-2dcb-4eab-a349-9747bdc6c38f}modifiedby'] & ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{98c456ec-e51b-4a61-a5e5-ca18d3e974fb}modifieddate'],
    loggedInUser() & today()
    ) ,
    submit: true,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: "Cancel",
    value: true,
    saveInto: ri!cancel,
    submit: true,
    style: "NORMAL",
    validate: false
    )
    }
    )
    )
    )

  • 0
    Certified Lead Developer
    in reply to Sameer Mohsin

    There is this functionality to make your code more readable.

  • a!localVariables(
    local!Category: rule!P_XYZ_GetRefData(type: "Category"),
    local!docsList: {},
    
    a!formLayout(
    label: "COMPLAIN FORM",
    contents: {
    a!sectionLayout(
    contents: {
    a!textField(
    label: "USER",
    labelPosition: "ADJACENT",
    value: ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{e6bc3159-2b12-4556-96c0-217891fd587b}useremail'],
    saveInto: a!save(
    ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{e6bc3159-2b12-4556-96c0-217891fd587b}useremail'],save!value
    ),
    refreshAfter: "UNFOCUS",
    required: true,
    readOnly: false,
    validations: {}
    )
    }
    ),
    a!dropdownField(
    label: "REQUEST TYPE",
    labelPosition: "ADJACENT",
    placeholder: "--- Select a Value ---",
    choiceLabels: local!Category['recordType!{f93bce3c-939a-4166-b96d-cb53ddd97f92}P_XYZ_REQCATEGORY.fields.{fcb692d4-c87f-4b65-a963-d1e66b232374}label'],
    choiceValues: local!Category['recordType!{f93bce3c-939a-4166-b96d-cb53ddd97f92}P_XYZ_REQCATEGORY.fields.{cc69a98c-f324-4465-9e0f-b00e48a727be}id'],
    value: ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{329875ac-5ae7-405d-bcd1-c24e26b2d287}requesttype'],
    SaveInto: a!save(
    ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{329875ac-5ae7-405d-bcd1-c24e26b2d287}requesttype'],save!value
    ),
    searchDisplay: "AUTO",
    required: true,
    validations: {}
    ),
    a!paragraphField(
    label: "DESCRIPTION",
    labelPosition: "ADJACENT",
    value: ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription'],
    saveInto: /*ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription']*/
    a!save(
    ri!userRequest['recordType!{20eafdce-4cae-46cf-982b-f8f20745d009}P_XYZ_REQUEST.fields.{c40f5c51-ca1a-4817-b87b-4619aac3e4ec}requestdescription'],save!value
    ),
    refreshAfter: "UNFOCUS",
    height: "MEDIUM",
    required: true,
    validations: {}
    ),
    a!fileUploadField(
    label: "UPLOAD FILE",
    maxSelections: 10,
    labelPosition: "ADJACENT",
    target: cons!P_XYZ_POINTS_TO_DOCS_FOLDER,
    value: local!docsList,
    saveInto: local!docsList,
    validations: {}
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Submit",
    saveInto: a!save(
    ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{f415d352-2dcb-4eab-a349-9747bdc6c38f}modifiedby'] & ri!users['recordType!{5f47d026-8eee-476e-95e4-126fe4a8bf12}P_XYZ_USERS.fields.{98c456ec-e51b-4a61-a5e5-ca18d3e974fb}modifieddate'],
    loggedInUser() & today()
    ) ,
    submit: true,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: "Cancel",
    value: true,
    saveInto: ri!cancel,
    submit: true,
    style: "NORMAL",
    validate: false
    )
    }
    )
    )
    )

    Thanks Stefan for telling me this. Actually I'm a beginner in appian so did'nt knew much about it as this is my first query being asked in the community.