Combining bot tasks on Control Tower

Is it possible to create a business process using code perspective and recording script.
Actually i have 3 files ,2 is code perspective(.xml) and one is record(.rpae) ,i use one xml file to get data from db and stored into a excel sheet and from that excel sheet i get data and use in my rpae file and get data from web and stored into excel sheet . After that i use 2nd xml file to get data from excel and insert into db.
So is it possible to create a business process to by adding of these three files , so i easily run the process every week.
Thank you…

@Jitendriya yes, sure. You can publish the 2 bot tasks and the recording to Control Tower and then combine them in one business process.
See the guide here: https://kb.workfusion.com/x/OwbmAg

Hi…
I have one code perspective to get data from db and stored into excel ,Ok if i run the code from
perspective it get the data from db and write into excel sheet, But when i publish the same code to control tower and run it as a business process it not write the data into excel sheet , but the BP process executed successfully .

Please tell me what i do or what did i wrong .
Thank you.

Does it manage to get any data from the database? Check the values of the variables.

I am use the java code in code perspective ,and where i check the variable and as per my code the data should write into excel sheet .

Please help me, Because this this is the last step of my complete project if i am successfully completed this process my project is done ,for which i am working on last 5 months .
Please help me .
Thank you .

Please share your bot task here.

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">

	
	<script><![CDATA[
		import java.io.FileNotFoundException;
		import java.io.FileOutputStream;
		import java.sql.Connection;
		import java.sql.DriverManager;
		import java.sql.ResultSet;
		import java.sql.SQLException;
		import java.sql.Statement;
		
		import org.apache.poi.ss.usermodel.Cell;
		import org.apache.poi.ss.usermodel.CellStyle;
		import org.apache.poi.ss.usermodel.CreationHelper;
		import org.apache.poi.ss.usermodel.Font;
		import org.apache.poi.ss.usermodel.IndexedColors;
		import org.apache.poi.ss.usermodel.Row;
		import org.apache.poi.ss.usermodel.Sheet;
		import org.apache.poi.ss.usermodel.Workbook;
		import org.apache.poi.xssf.usermodel.XSSFWorkbook;

		String[] columns = ["ID","CONSULTANT_NAME","CLIENT_NAME","PORTAL_LINK"];
		String xlfile = "D:\\Test.xlsx";
		String id,infoid, consultantname,quickbookname,clientname,portallink,createdby,status,date ;
		Connection conn = null;
		Statement stmt = null;
		String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
		String DB_URL = "Mydb url?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
		String USER = "root";
		String PASS = "";
		
	    // Create a Workbook
	    Workbook workbook = new XSSFWorkbook(); 
	    CreationHelper createHelper = workbook.getCreationHelper();
	    Sheet sheet = workbook.createSheet("Consultant_Data");
	    // Create a Font for styling header cells
        Font headerFont = workbook.createFont();
        headerFont.setBold(true);
        headerFont.setFontHeightInPoints((short) 14);
        headerFont.setColor(IndexedColors.RED.getIndex());
        // Create a CellStyle with the font
        CellStyle headerCellStyle = workbook.createCellStyle();
        headerCellStyle.setFont(headerFont);

        // Create a Row
        Row headerRow = sheet.createRow(0);
        // Create HEADING cells
        for(int i = 0; i < columns.length; i++) {
            Cell cell = headerRow.createCell(i);
            cell.setCellValue(columns[i]);
            cell.setCellStyle(headerCellStyle);
        }

		try {

			Class.forName(JDBC_DRIVER);
			conn = DriverManager.getConnection(DB_URL, USER, PASS);
			stmt = conn.createStatement();
			String query = "SELECT * FROM psg_consultant_client ORDER BY client_name";
			ResultSet rs = stmt.executeQuery(query);

			System.out.println("Connection successfull`");
			int i = 0;
			
			int rowNum = 1;
			while (rs.next()) {
				
				infoid = String.valueOf(rs.getInt("info_id"));
				id = String.valueOf(rs.getInt("employee_master_id"));
				consultantname = rs.getString("consultant_name");
				quickbookname = rs.getString("quickbook_name");
				clientname = rs.getString("client_name");
				portallink = rs.getString("portal_link");
				date = String.valueOf(rs.getTimestamp("created_date"));
				createdby = String.valueOf(rs.getInt("created_by"));
				status = String.valueOf(rs.getInt("status"));
				
				// Create Other rows and cells with employees data
			    
			    Row row = sheet.createRow(rowNum++);

		        row.createCell(0)
		                .setCellValue(id);

		        row.createCell(1)
		                .setCellValue(consultantname);

		        row.createCell(2)
		        		.setCellValue(clientname);
		 
		        row.createCell(3)
		                .setCellValue(portallink);				
				
			}
			// Resize all columns to fit the content size
		    for(int i1 = 0; i1 < columns.length; i1++) {
		        sheet.autoSizeColumn(i1);
		    }

		    // Write the output to a file
		    FileOutputStream fileOut = new FileOutputStream(xlfile);
		    workbook.write(fileOut);
		    fileOut.close();

		    // Closing the workbook
		    workbook.close();
				
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		

	


		
		
	]]></script>

    <export include-original-data="true"></export>

</config>
1 Like

Hi…
@ashapkina did you find any solution for this above problem.

Hi @Jitendriya it is possible that you don’t have jdbc driver on the Control Tower side, so the bot task is not executed, but as you use Try-Catch it doesn’t fail. Check out these topics

HI…
So can you send me the demo code how to connect to mysql and get data form db and stored into excel sheet.
if its is possible using groovy script then please send me the groovy script .

@Jitendriya I though the code you shared above worked correctly in the Studio, doesn’t it?

If I run it from code perspective, it works fine. But when I am running the same code from Control Tower as a business process, it is not working…

You need to add the jar to Control Tower side as described in the topics I shared above.

Thank you…@ashapkina It worked fine…

1 Like

Hi …
Can i run the business process from control tower where Custom Script is used , Because i am used custom script in my recording and run form control tower but it showing error. (from recorder its working perfectly) .
Tell me how can i fix it.
Thank you…

Is it this error?

Thank you This one is working… But
now i face another problem if i run from recorder my code is working fine but when i publish it from control tower its showing the following error…

Step name ‘Daywise_newDb’ has failed. Reason: ‘[urn:uuid:8EEB5D4CD98316C1C3156827991048539] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=NumberFormatAction.ftl,id=411,name=Optional[NumberFormatAction],parent=405,nextSibling=412,arguments=ActionArguments[outputLocale=[en-IN],outputMask=[00],inputLocale=[en-IN],xsi:type=[recorder:NumberFormatAction, recorder:NumberFormatAction],pollingInterval=[300],active=[true],inputMask=[00],input=[${day1_min_part}],targetVariable=[day1_min_num],delay=[0],timeoutMs=[10000],awaitTimeout=[5000],direction=[STRING_TO_TYPE]]]’

Please tell me the solution …
Thank you…

@Jitendriya please export the error log and share here.

can i share you personally