You are viewing limited content. For full access, please sign in.

Question

Question

CSV File from Form to Email

asked on April 2

I need to create a CSV file from a form and email it to our Network Administrator.

I created a workflow copying Forms fields to create a CSV file with workflow

But my Selection Collection is Empty.  Any Assistance would be great. 

0 0

Replies

replied on April 2

Hi Kimberly, did you select any table or collection fields from the retrieve bp variables activity? Only these 2 types can be used by For Each Row activity. 

2 0
replied on April 3 Show version history

Thanks for the reply. I am in Workflow 11 (if that helps) and that is not an option (see picture below). 

I have attempted a different way,  as I am not sure why I need the For Each Row (I was just following the directions from the first person).

 I now have all green in workflow, It states all is success, I put a token tracker and the tokens are taking values, and it creates the CSV file BUT it is blank. I AM SO CLOSE. What am I missing? 

 

 

Here is my script. 

                // Specify the full path for the CSV file.
                string serverName = "I put server name here";  // Replace with your Laserfiche Server name
                string repositoryName = "I put it here"; // Replace with your repository name
                string filePath = "\\\\" + serverName + "\\" + repositoryName + "\\Information Services\\test\\ARFData.csv";

                try
                {
                    // Build the CSV string.
                    System.Text.StringBuilder csvContent = new System.Text.StringBuilder();

                    // Add header row (only if the file does not exist)
                        if (!System.IO.File.Exists(filePath))
                        {
                            csvContent.AppendLine("ReportLine01,ReportLine02");
                        }

                        // Retrieve token values
                        string reportLine01 = GetTokenValue("ReportLine01").ToString();
                        string reportLine02 = GetTokenValue("ReportLine02").ToString();

                        // Properly format CSV row (handling commas and quotes)
                        csvContent.AppendLine("\"" + reportLine01 + "\",\"" + reportLine02 + "\"");

                        // Append to the CSV file instead of overwriting it
                        System.IO.File.AppendAllText(filePath, csvContent.ToString());
                    }
                catch (Exception ex)
                {
                    // Log any errors.
                    System.Diagnostics.Trace.WriteLine("Error creating CSV file: " + ex.Message);
                }

0 0
replied on April 6

If I got it right, you wanted to write the csv content to the repository entry created by the Create CSV file activity. Here's the correct way to get the entry:

1. In the script activity, find script's Default Entry property, select Other Entry -> Select -> Create CSV file: OutputEntry

2. Use the default entry in your script by accessing this.BoundEntryInfo, here's mine:

                using (DocumentInfo csv = (DocumentInfo)this.BoundEntryInfo) // Create CSV file activity's output entry
                {
                    // Build the CSV string.
                    System.Text.StringBuilder csvContent = new System.Text.StringBuilder();
                    // Add header row
                    if (csv.PageCount == 0)
                    {
                        csv.AppendPage();
                        csvContent.AppendLine("ReportLine01,ReportLine02");
                    }

                    // Retrieve token values
                    string reportLine01 = GetTokenValue("ReportLine01").ToString();
                    string reportLine02 = GetTokenValue("ReportLine02").ToString();

                    // Properly format CSV row (handling commas and quotes)
                    csvContent.AppendLine("\"" + reportLine01 + "\",\"" + reportLine02 + "\"");

                    // Append to the CSV file instead of overwriting it
                    PageInfo page = csv.GetPageInfo(1);
                    string existingText = string.Empty;
                    if (page.HasText)
                    {
                        existingText = page.ReadPagePartAsString();
                    }
                    page.WriteTextPagePart(existingText + csvContent.ToString());
                    page.Save();
                }

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.