Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Uploading file to case using script



we have created a webform on our customer-pages that generates a ticket with an attached csv containing the information that was entered by the customer.
This is working as expected. We also wish to allow the customer to upload their own csv/excel file that is then attached as an aditional attachment in the ticket. This we are not able to to.

We have the following in our html-script:

<div id='fileList'>
    <h4>Last opp FI-tabell </h4>
    <input type="file" name="attachment_[]" id='newFiles' multiple />
    <input type="hidden" name="attList" id="attList" value="" >

which is inside:

<form method="post" name="mainForm" enctype="multipart/form-data" action="%AuthProgram%&withFrame=1&action=safeParse&includeId=bestillingskjema_post&key=****">

This looks ok, and the customers are seemingly able to upload files here. 

In our SO-script we have:

Vector vIds;
Attachment att;
Integer atId =;
Byte[] byteContent = csv.toByteArray();
String base64 = encodeBase64(byteContent);
Attachment a;
Integer attId =;
Integer size = a.saveBase64(base64);

vIds attached to a message later in the script. 

The bottom half of this is a csv generated earlier in the script from the informaiton the user inputs. This works as expected. 
The former part seemingly generates a csv, but cannot be opened. 

For the upper half I have tried replacing "attachment_[]" with "attList", and I have also tried the following: 

Vector vIds;
String[] attachments = getParserVariable("attList").split(",");
for (Integer i=0;i<attachments.length(); i++)
  Attachment att;
  att.load( attachments[i].toInteger() );
  Integer atId =;

In this case, no file is generated at all. 

It seems obvious that I am missing something, but cannot figure out what.

Any help or input is much appreciated! We are ready for deployment of the form, but are missing this last part. 



Rikke Mohn

RE: Uploading file to case using script


Would expect that this should work;

Vector vIds = Vector(saveAllCgiAttachments("attachment_[]"));
Von: Michel Krohn-Dale 1. Jul 2020