BulletedListFiles

From SMTX Wiki
Revision as of 22:44, 25 May 2020 by Smtxwiki (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Case: we build a list of Names, they can all have multiple attachments linked to them.

Data is stored in a simple datastore, with 2 fields : Name & Attachments.

Goal is to show, when editing the entry in a form, the already uploaded files, but they need to be clickable :)

The issue is that files are renamed when saved during the process (so you do not know the exact filename, unless the ticket is started).

Secondly, in the workflow, you know only the full link to the file.

So how did we pull it off?

First, in the form; make a field of the type multi-upload.

Call it 'NewAttachments'.

Now, in the process, we need to add the '<a href="..">' & '</a>' HTML codes around each entry (remember, we support multi file upload!!)

Make a first variable called 'FilePlaceholder' (in our example, it got ID 1136)


So, start with a multiplier step, multiply per file. Edit your variable as follows:

 #REPLACE-VARIABLE-1136#||<a href="#REPLACE-MULTIPLIERDATA-4892||File#">#REPLACE-MULTIPLIERDATA-4892||File#</a> 

This will make a nice piped-list of all entries, with a link.

The start value of the variable is empty, but it gets added again and again in the front, so the addition in each multiplier step happen at the end.

Problem is the || that will be there at the begiining of the varialbe and will mess stuff up.

So we need to get rid of it.

Therefor, make a second variable, call it : AllFiles (ID was 1135 in my setup) We will remove the first instance of || by this calculation:

 IIF('#REPLACE-VARIABLE-1136#' != '', SUBSTRING('#REPLACE-VARIABLE-1136#', 2), '') 

You can now show this field in the form, but you need to replace the || by bullets. So the calculation on the field will need to be (you might need to go in edit mode of this page to see the code):

   '<UL><LI>'+REPLACE('#REPLACE-FORMFIELD-YOURFIELD#','||','</LI><LI>')+'</LI></UL>'  

Finally, if you want users not to replace the current uploaded files with new ones, make another hidden field, that lists the current files, but put || in front of it. Call it for example: Current_attachments

In the process, make a new variable, call it 'All Files Combined (new and old)'

the initial value is then :

 #REPLACE-VARIABLE-1135##REPLACE-FORMFIELD-Current_attachments# 

remember : variable 1135 was our variable with all files, piped; where we removed the first pipe ||, the field that we add after it has the || as a start, as defined in the hidden field.

examples:

 http://dev.ssp7.smt-x.com/Forms/form.aspx?id=281
https://ssp-q.siemens.be/Forms/form.aspx?id=1250 (tab: other)