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.
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
Hi shrutij9485,
Please try below code. It will save the document in documents folder and document ID to database table
a!formLayout( label: "Form", contents: { a!cardLayout( contents: { a!fileUploadField( label: "File Upload", labelPosition: "ABOVE", target: cons!PDS_DOCUMENT_FOLDER, value: ri!Document.documentId, saveInto: a!save(ri!Document.documentId, save!value), validations: {} ) }, height: "AUTO", style: "NONE", marginBelow: "STANDARD" ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Submit", saveInto: a!writeToDataStoreEntity(cons!PDS_DATASTORE_DOCUMENT_CONSTANTS, ri!Document, "Success", ""), submit: true, style: "PRIMARY" ) } ) )
I tried this solution but in process model itis showing that data cannot be written in database
The above solution is generally correct - if you're having further issues then you'll need to provide more detail with respect to exactly what you're trying and exaclty what error you're receiving in the process instance.
Hey Mike I tried the solution it works but only if 1 doc is being uploaded, is there any way where I can upload multiple docs?, because I tried uploading multiple but it only gets the first one selected and not the other
Yeah, You can upload multiple docs at a time. You have to make sure that your variable must be a list of number integer array. And check maxSelection parameter value which shouldn't be 1, If it is 1 then you can just select only one file not multiple files.
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.
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 ) } ) ))
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.