0

upload image to another table or copy image to another table

I stumbled on a lot of forum post talking about how images could not be moved without downloading the image first. It took a bit of work. The idea was to use a page where users can upload an image that would be stored in a table based on other selections they made on the page.

So one image field for upload and a target table where the image should be stored.
 

let rec := first((select targettable)[selection to have a result of one]); //unless you need to loop through many
let filename := text('Logo upload'); //get the filename form the image-field
filename := item(split(filename, "/"), 1); //filename is returned as recordId/filename so this chopps of the bit we dont need
let targetRecord := record(targettablename,rec.Id); //using record() is what makes this works
let url := shareFile('Logo upload'); //create a link to the file
importFile(targetRecord, url, filename); //import it into the targetrecord as an attachedment
rec.(Logo := filename); //move the attachement to an image-field in the target record
removeFile('Logo upload'); //some optional cleanup when using as a cut and paste or upload field
'Logo upload' := null //optional reset the upload-field  to null

Reply

null

Content aside

  • 2 days agoLast active
  • 7Views
  • 1 Following