validate data while using import tool

Confluence User - 15 Dec, 2016

I am using import tool so that a user can upload an excel file and all  the data gets populated. However, what i want is that the first two columns of the excel file should be validated against the form elements that if the data exists over then then populate the row otherwise show some message. 

Example:
              School name, School Address are two columns which should be validated if it exists in the form on the radio buttons entry only then populate.

Any help would be appreciated.
Thanks. 

forms;import;tools

5


15 Dec, 2016
confluenceUser
confluenceUser

There are a couple of ideas that I can think of,

Firstly, if the default validation of the import tool doesn't fit your needs, can't you try creating your own validation schemes?
Otherwise, you could always drop in a BeanShell tool plugin right after the ImportTool to validate the file imported. The process could be allowed to change states on the basis of a workflowVariable flag that you set in the BeanShell tool.

Hope this would be helpful.

Thanks

15 Dec, 2016
confluenceUser
confluenceUser

I wrote a BeanShell a while back to append the username of a person to a file that he uploaded in a form. This was supposed to be a process tool plugin to update the fileName. I believe you can add a process tool BeanShell plugin after you import a file to read its contents and do the necessary validations. Based on what the validation results are, you can set a Workflow Variable to take the process to different stages of the workflow where you can display proper errors messages etc.
Here is the BeanShell that I wrote:

 

public void updateFileName(){
try{
String sourceDirectory="";
ApplicationContext ac = FileUtil.getApplicationContext();
String formUploadPath = SetupManager.getBaseDirectory();
SetupManager setupManager = (SetupManager) ac.getBean("setupManager");
String dataFileBasePath = setupManager.getSettingValue("dataFileBasePath");
if(dataFileBasePath!=null && dataFileBasePath.length() > 0){
sourceDirectory=dataFileBasePath;
}
else{
sourceDirectory=formUploadPath;
}
String destinationDirectory = sourceDirectory+File.separator+"filesWithRequesters"+File.separator+"app_formuploads"+File.separator+"fileUpload"+File.separator+"#assignment.processId#"+File.separator;
sourceDirectory+=File.separator+"app_formuploads"+File.separator+"fileUpload"+File.separator+"#assignment.processId#"+File.separator;
String sourceFilePath = sourceDirectory+"#form.fileUpload.file#";
String fileExtension = FilenameUtils.getExtension(sourceFilePath);
String destinationFilePath = FilenameUtils.removeExtension(destinationDirectory+"#form.fileUpload.file#");
destinationFilePath += "_"+"#form.fileUpload.requester#."+fileExtension;
File sourceFile = new File(sourceDirectory+"#form.fileUpload.file#");
File destinationFile = new File(destinationFilePath);
FileUtils.copyFile(sourceFile,destinationFile);
}
catch(Exception e){
System.out.println("Some error occurred in renaming the file. "+e);
}
}
return updateFileName();
 

 

Hope this would be useful.

Thanks,
Ashutosh

15 Dec, 2016
confluenceUser
confluenceUser

Ashutosh Tripathi Thanks so much. Works like a charm. 

15 Dec, 2016
confluenceUser
confluenceUser

I know this BeanShell isn't the best that I could have written (this was just supposed to be a POC) but I thought it would give you a good place to start. Glad that helped. :)

15 Dec, 2016
confluenceUser
confluenceUser

yeah all i needed was a sample and thank you so much for all the help.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print