You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Hi ,

Anyone Know that how to get login user Name form the  beanshell plugin?is can be using hash variable?

I  tryed it like this.but its not works.is there any idea to solve this  proble?aslo i tryed using #form.name#.but its also not working?

import java.util.*;
import org.apache.commons.collections.SequencedHashMap;
import java.sql.*;
import org.joget.workflow.model.service.*;

Map result = new SequencedHashMap();
WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
String test ="#performer.wp1_act1.firstName#";
String ttt;
Connection con = null;

try {
 Class.forName("com.mysql.jdbc.Driver").newInstance();
 con = DriverManager.getConnection("jdbc:mysql://localhost:3307/sampledb?useUnicode=true&characterEncoding=UTF-8", "root", ""); // declare datasource

 if(!con.isClosed()){
  PreparedStatement stmt = con.prepareStatement("select myBackUser, username from dir_user where id='"test"'"); // SQL query

  ResultSet rs = stmt.executeQuery();
Map result = new SequencedHashMap();
  while (rs.next())

Unknown macro: { // print "id -- name" for each row returned    System.out.println(rs.getString(1) + " -- " + rs.getString(2));ttt=rs.getString(1);  }

 }
} catch(Exception e) {
 System.err.println("Exception from BeanShell activity: " + e.getMessage());
} finally{
 try

Unknown macro: {  if(con != null)   con.close(); }

catch(SQLException e) {}
}

result.put("bvbb",ttt);
return result;

  • No labels