1
0
-1

Hi, I am doing a form with upload component and using bean shell script (Post Form Submission Processing) to save the uploaded file into db2 database. 


But I encounter a problem that I could not get the actual path that store the uploaded file. The way how joget store the uploaded file is like UUID (folder name) like screenshot below:



I manage to get the file using FileUtil.getFile, below is the example code in bean shell script:

import org.joget.commons.util.LogUtil;
import org.joget.apps.form.service.FormUtil;

String tableName = "stao_form_filling_03";
String recordId = "field2"; //this is my upload component field id
String fileNameList = "#form.stao_form_filling_03.field2#"; //this is download.png

File jogetUploadFile = FileUtil.getFile(fileName, tableName, recordId);
LogUtil.info("File Name", jogetUploadFile.getName());
LogUtil.info("File Path", jogetUploadFile.getAbsolutePath());

String jogetUploadPath = FileUtil.getUploadPath(tableName, recordId);
LogUtil.info("jogetUploadPath", jogetUploadPath);


When I'm using jogetUploadFile.getAbsolutePath() or FileUtil.getUploadPath(tableName, recordId), it shows the path with upload component field id like below:

/home/jboss/wflow/app_formuploads/stao_form_filling_03/field2/download.PNG

But the actual path that store the uploaded file is like below:

/home/jboss/wflow/app_formuploads/stao_form_filling_03/192da6fe-a03214a4-2d8e94dd-7d54bfc0/download.PNG


I know that we should use primaryKeyValue to use getFile, but I don't how to get it in bean shell script (Post Form Submission Processing). 

public static java.io.File getFile(java.lang.String fileName, java.lang.String tableName, java.lang.String primaryKeyValue) throws java.io.IOException

Gets the file from target upload directory of a form data record


Is there anyway to get actual file path (with UUID folder name) uploaded from joget in Bean shell script or get the primaryKeyValue in Bean shell script?


Thanks.



    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, perhaps you could try removing the line "String recordId = field2" and check whether there is a "recordId" variable already automatically injected into the code. 

        CommentAdd your comment...