Hello,
I am looking for a simple script I can modify using the Script Rule feature of Laserfiche Cloud. I would like to generate a CSV file from multi value tokens I can setup in the rule editor. The goal is to push information to another system.
I have already setup and successfully tested the C Sharp script below but it only puts in one row in the CSV. How can I modify this script to apply multiple rows from the multi value tokens above.
namespace Your.Namespace { using System; using System.Collections.Generic; using System.Threading.Tasks; using System.IO; // The class name is used in the "Class name" property in the rule designer page public class ExportClientData { // Ensure your method uses the same signature as used below. // The name of the method that you will call is used in the "Method name" property in the rule designer page public Task<IDictionary<string, object>> CreateClientCSV(IDictionary<string, object> arguments) { // Retrieve your input parameters from the names provided under "Input" in the rule designer page. var vPatientChartNumber = arguments["PatientChartNumber"]; var vPatientLastName = arguments["PatientLastName"]; var vPatientFirstName = arguments["PatientFirstName"]; var vPatientPhone = arguments["PatientPhone"]; var vApptDate = arguments["ApptDate"]; var vApptStartTime = arguments["ApptStartTime"]; var vApptEndTime = arguments["ApptEndTime"]; var vApptLength = arguments["ApptLength"]; var vApptStatus = arguments["ApptStatus"]; var vApptProviderCode = arguments["ApptProviderCode"]; var vApptProviderLastName = arguments["ApptProviderLastName"]; var vApptProviderFirstName = arguments["ApptProviderFirstName"]; var vApptResourceCode = arguments["ApptResourceCode"]; var vApptResource = arguments["ApptResource"]; var vApptReasonCode = arguments["ApptReasonCode"]; var vApptReason = arguments["ApptReason"]; var vApptNote = arguments["ApptNote"]; var filepath = "C:/DA Tools/TestFiles/client.csv"; using (StreamWriter writer = new StreamWriter(new FileStream(filepath, FileMode.Create, FileAccess.Write))) { writer.WriteLine("PatientChartNumber,PatientLastName,PatientFirstName,PatientPhone,ApptDate,ApptStartTime,ApptEndTime,ApptLength,ApptStatus,ApptProviderCode,ApptProviderLastName,ApptProviderFirstName,ApptResourceCode,ApptResource,ApptReasonCode,ApptReason,ApptNote"); writer.WriteLine(vPatientChartNumber + "," + vPatientLastName + "," + vPatientFirstName + "," + vPatientPhone + "," + vApptDate + "," + vApptStartTime + "," + vApptEndTime + "," + vApptLength + "," + vApptStatus + "," + vApptProviderCode + "," + vApptProviderLastName + "," + vApptProviderFirstName + "," + vApptResourceCode + "," + vApptResource + "," + vApptReasonCode + "," + vApptReason + "," + vApptNote); } // Return the information back to your script rule. return Task.FromResult<IDictionary<string, object>>( new Dictionary<string, object> { // The dictionary key should match the name used under "Output" in the rule designer page. ["output"] = "CSV Successfully Created" }); } } }
Also please if you could post the entire code in the solution so non coders could simply copy and paste this script it might just make for a better world for everyone.
Thank You