1
0
-1

I am using import tool in post processing of the form . In the store data form i have add the field should have the value from the database data only . but on excel upload it is not checking this data . 

I have added the below bean shell  code for validation .


the record id in the bean shell is returning null .

but this is also not working 

import java.sql.*;
import java.util.*;
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.dao.FormDataDao;
import javax.sql.DataSource; 
import org.joget.apps.app.service.AppUtil; 
import org.joget.commons.util.LogUtil; 


 
public boolean validate(Element element, FormData formData, String[] values) {
    boolean result = true;
    
    FormRowSet f = new FormRowSet();
    f.setMultiRow(true);
    
    FormDataDao formDatadao=(FormDataDao) AppUtil.getApplicationContext().getBean("formDataDao");
     
    if (values != null) {
    
        String recordId = "#requestParam.lo_number#";
   
        DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource");
        con = ds.getConnection();
       
        if(!con.isClosed()){
                    System.out.println("Connected.....");
           
                    String sql = "SELECT select c_type from app_fd_types where c_type =?";
                    PreparedStatement stmt = con.prepareStatement(sql);
                    stmt.setString(1, recordId);
                    ResultSet rs = stmt.executeQuery();
                    
                     int size = 0;
                     while (rs.next()) {
                            size++;
                         }
                   
                        if (size == 0){
                            System.out.println("Not valid  Type");
                            String id = FormUtil.getElementParameterName(element);
                            formData.addFormError(id, "Not valid  Type");
                            con.close();
                            return false;
                        }
                        
                    
   
        } //Connection 

            con.close();
            return result;
            }
}
 
//call validate method with injected variable
return validate(element, formData, values);


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, there is not enough information to really help.

      It's unclear what is meant by excel upload is not checking this data. What data is that?

      For the record id being null, the code uses "#requestParam.lo_number#", so you need to check to make sure that there is a valid "lo_number" parameter in the URL when you submit the form.


      1. Vimi

        Hi , i am using import tool in port processing . So in the file upload i will be uploading an excel which is used for importing the data to the store form . i need to do a validation check for each fields like the data uploading in excel is from the master table data itself . so i can be sure no junk data is uploaded . 


        In the store data form , for the validation fields, it is a select box and i have put load data from table in the table . but after that while uploading it was accepting all value .So i added the ablove code in the validation field with bean shell . 

        But here i have mapped the lo_number field of the form to a column in the excel . But while debugging it is returning null value .


        How to get the record value that is being imported by excel and do a validation on its data .



      CommentAdd your comment...