Hi Team,
I am working with the documentsChatField in Appian. After uploading a document, I want to pass it to the chat field for verification. If the verification is successful, I need to save the document details in the database.
documentsChatField
Could you please guide me on how to achieve this? Is it possible to trigger document verification immediately after upload and then conditionally persist the document metadata based on the verification result?
Discussion posts and replies are publicly visible
Hope you are uploading a document through fileUploadField and passing it to documentsChatField for conversation.You want to store the document after verification, but how are you concluding the verification of the document?But just for information, the documentsChatField does not support saveInto and you cannot extract data from it- it's just a session-based chat.
I have successfully implemented file upload using the fileUploadField component and obtained the document ID after upload. I would like to pass this document ID to the documentsChatField through a local variable in order to initiate a chat session with the uploaded document.
fileUploadField
rajeshp7374 said: I would like to pass this document ID to the documentsChatField through a local variable in order to initiate a chat session with the uploaded document.
Are you facing any issue with this?
The functionality stops working when I pass the new document ID. Please find the code below.a!localVariables( local!documentId, local!selectedValue, local!gridData: a!queryEntity( entity: cons!DS_SEARCH_DOCUMENT, query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "Id", operator: "in", value: tointeger(local!selectedValue), applyWhen: a!isNotNullOrEmpty(local!selectedValue) ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50) ), fetchTotalCount: false ).data, local!docid: todocument(index(local!gridData, "documentId", {})), a!sectionLayout( label: "Section", contents: { a!fileUploadField( label: "File Upload", labelPosition: "COLLAPSED", fileNames:fv!file.name, value: local!documentId, saveInto: { local!documentId, a!save( ri!Document, 'type!{urn:com:appian:types}Document_Upload_CDT'( documentId: local!documentId, documentName:local!documentId, /*attachmentType:fv!file.extension,*/ description: "test", isActive: true(), CreatedBy: 12, CreatedOn: now() ) ) }, maxSelections: 1, target: cons!DOCUMENT_SEARCH_UPLOAD ), a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Upload", submit: true, icon: "Upload", style: "SOLID" ) } ), a!documentsChatField( label: "Documents Chat", documents:if(todocument(a!isNotNullOrEmpty(local!documentId)),local!docid,{}), height: "AUTO" ), a!gridField( label: "Read-only Grid", labelPosition: "ABOVE", data: a!queryEntity( entity: cons!DS_SEARCH_DOCUMENT, query: a!query(pagingInfo: fv!pagingInfo), fetchTotalCount: true ), columns: { a!gridColumn( label: "Id", value: a!defaultValue(fv!row.Id, "–"), sortField: "Id", align: "END" ), /*a!gridColumn(*/ /*label: "Document Id",*/ /*value: a!defaultValue(fv!row.documentId, "–"),*/ /*sortField: "documentId",*/ /*align: "END"*/ /*),*/ a!gridColumn( label: "Document Name", value:document(fv!row.documentId,"name"), sortField: "documentName" ), a!gridColumn( label: "Attachment Type", value: document(fv!row.documentId,"extension"), sortField: "attachmentType" ), a!gridColumn( label: "Description", value: a!defaultValue(fv!row.description, "–"), sortField: "description" ), a!gridColumn( label: "Is Active", value: if( isnull(fv!row.isActive), "–", a!richTextDisplayField( value: if( fv!row.isActive, a!richTextIcon( icon: "check", altText: "Yes", color: "#138901" ), a!richTextIcon( icon: "times", altText: "No", color: "SECONDARY" ) ) ) ), sortField: "isActive", align: "CENTER" ) }, selectable: true, selectionValue: local!selectedValue, selectionSaveInto: local!selectedValue, height: "AUTO", shadeAlternateRows: true ) } ), )
Replace local!docid with toDocument(local!documentId) directly in chat field.Fix the if() condition - remove todocument() wrapping the booleanCapture upload via index(fv!files, 1, null())
The AI components can not access 'un-submitted' files. Files that are freshly uploaded live in a special hidden part of the Appian back-end filesystem and until recently even functions like "document()" would error when trying to use them before the document was "submitted" (though this has been updated in the past ~2 versions).
To handle your use case though, you'll need to do one of these: