Hi there,
I have created a button to generate CSV file but after clicking on button- page redirects to home page. I want to create document link when clicking on button so that file get downloaded. How can I do this in interface?
Thanks
Discussion posts and replies are publicly visible
Hello manjit.1486,
Does this button trigger a Start process? If so I would recommend you to use a Record/Related actions to perform this and try using a User Input task where the user has a summary of what kind of document and what data is there and so on, add a document download link using a!documentDownloadLink() pass your generated document as the value here. I guess this would help and this is what you were asking for. If not please ignore.
I am using rich text and startprocess link. Want to generate a file document link.
manjit.1486 said:startprocess link
You wouldn't use a!startProcessLink() for this. You'd use a!StartProcess(), run the process with chaining enabled, and pass the generated document Id back into your interface.
below is the code: Please verify: a!buttonArrayLayout( buttons: { a!buttonWidget_23r3( label: "Generate File", value: cons!IPA_VAL_DATA, saveInto: { ri!buttonValue, a!save( ri!assign.preparedby, local!loggedInUser ), a!startProcess( processModel: cons!IPA_DATA_PROCESS_MODEL, processParameters: {employee:ri!employee,address:ri!address,tax:ri!tax, assigne:ri!assigne buttonValue:ri!buttonValue } ) }, submit: false(), validate: false(), style: "SECONDARY", ) }, align: "START", marginAbove: "STANDARD" ),
a!buttonArrayLayout( buttons: { a!buttonWidget_23r3( label: "Generate File", value: cons!IPA_VAL_DATA, saveInto: { ri!buttonValue, a!save( ri!assign.preparedby, local!loggedInUser ), a!startProcess( processModel: cons!IPA_DATA_PROCESS_MODEL, processParameters: { employee:ri!employee, address:ri!address, tax:ri!tax, assigne:ri!assigne buttonValue:ri!buttonValue }, onSuccess: { a!httpResponse( statusCode: 200, headers: { a!httpHeader( name: "Content-Type", value: "application/json" ) }, body: fv!processInfo ) } ) }, submit: false(), validate: false(), style: "SECONDARY", ) }, align: "START", marginAbove: "STANDARD" ),
Can you check?
Why do you try to put a HTTP response into a button? That will not do anything.
What Mike tried to explain, is that you need to store the ID of the generated document from the process into a local variable. Then show a link component to allow the user to download the file.
a!buttonArrayLayout( buttons: { a!buttonWidget_23r3( label: "Generate File", value: cons!IPA_VAL_DATA, saveInto: { ri!buttonValue, a!save( ri!assign.preparedby, local!loggedInUser ), a!startProcess( processModel: cons!IPA_DATA_PROCESS_MODEL, processParameters: { employee:ri!employee, address:ri!address, tax:ri!tax, assigne:ri!assigne buttonValue:ri!buttonValue }, onSuccess: { a!save(local!docId,fv!processInfo), ) }, onError: a!save( local!errorMessage, "Error Exporting File to Excel" ) ) }, submit: false(), validate: false(), style: "SECONDARY", ) }, align: "START", marginAbove: "STANDARD" ),
You need to read the details in the rule description for a!startProcess - granted it's not SUPER well explained at a surface level, but it's also not that hard. The highlighted snippet is what you're missing in the above iteration:
Thanks for the information. I am following the above highlighted snippet. But when I used that local variable in documentdownload link. It gives an error.
a!buttonArrayLayout( buttons: { a!buttonWidget_23r3( label: "Generate File", value: cons!IPA_VAL_DATA, saveInto: { ri!buttonValue, a!save( ri!assign.preparedby, local!loggedInUser ), a!startProcess( processModel: cons!IPA_DATA_PROCESS_MODEL, processParameters: { employee:ri!employee, address:ri!address, tax:ri!tax, assigne:ri!assigne buttonValue:ri!buttonValue }, onSuccess: { a!save(local!docId,fv!processInfo.pv.docId), ) }, onError: a!save( local!errorMessage, "Error Exporting File to Excel" ) ) }, submit: false(), validate: false(), style: "SECONDARY", ) }, align: "START", marginAbove: "STANDARD" ), a!linkField( label: "Download document", labelPosition: "ABOVE", links: { a!documentDownloadLink( label: document( documentId: local!docId, property: "name" ), document: local!docId ) } )
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function 'document' [line 945]: The passed parameter(s) are of the wrong type. Received the type Text.What I am missing? I tried change the type - still gets an error. pv.docId is integer type.