Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
shajipappan Contributor.
Contributor.
241 views

Using Workflow,How to save the result of a script in Excel file and download the file using workflow

I have to create a script/query in a workflow which can return all the roles associated with a user.

And i need this result to be saved in an Excel File and need to download this Excel file using the same workflow.

Any idea how to implement this?

0 Likes
6 Replies
Highlighted
pdeneu Super Contributor.
Super Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

Hello,
Option one is to save the result in a file on the filesystem / tomcat directory and generate the url to the file out of this.
Option two: generate an object out of this and save the information in an attribute. While using a kind of download button generate the csv on the fly.
Regards,
Philipp


--
https://www.lanworks.de
shajipappan Contributor.
Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

Hi thanks for your reply. 

Do you know how we can save this result in a file using the workflow.

Also how we can include a download option in the workflow?

Even if we include a button i think it should point to some location where it should download the file. and from where it should access the file. Is there any particular code for this or can we achieve this using workflow fields and the java functions inside the fields?

0 Likes
pdeneu Super Contributor.
Super Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

Hey try to use jquery / javascript for this:

i found this quite fast via google:

https://code-maven.com/create-and-download-csv-with-javascript

 

Regards,

Philipp


--
https://www.lanworks.de
shajipappan Contributor.
Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

Thanls Philipp 🙂
0 Likes
psundqvist Contributor.
Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

I'm not sure if this is what you are trying to do, but if you want the user to be able to download the file from the form to their workstation you can do something like this:

Create an html form field with an onload event:

function handleFileSelect(evt){

var myString =form.getValue("FileContent");
saveAs( data2blob(myString.replace(/\|/g,"\r\n")), "UserRoles.csv" );

}

document.getElementById('myFile').addEventListener('click', handleFileSelect , false);

also add the html content:

(function () {return "<input type='button' value='Export to file' id='myFile'>" ;})();

 

Then create a text form field to hold the content of the file (called FileContent in my example) and populate it with your roles with an appropriate separator.

shajipappan Contributor.
Contributor.

Re: Using Workflow,How to save the result of a script in Excel file and download the file using work

Thanks for your help am comments.
It helps me. 🙂
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.