How to call db plugin inside <script><![CDATA[---- ]]></script> or as a separate bot task?

Please guide me how can I implement below scenario.

  • Open a web app, due few steps to create for example an employee.
  • Query the DB to get the new emp id
  • Go back to web app and do more operations on newly created employee.

Can the DB plugin call be included inside the robotics-flow, i.e. is after

Or it requires 3 steps.

Bot task one to do first web interface.

Bot task two for DB operations

Bot task three to resume web operations.

You cannot put the plugin inside the script, but you can put it between scripts inside the robotic-flow plugin.

Below is an example based on your script from this topic.

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

	<robotics-flow>
		<robot driver="universal" close-on-completion="true"
			start-in-private="false">
			<capability name="SEARCH_ALL_WINDOWS" value="true" />
			<capability name="CLOSE_ALL_WINDOWS" value="false" />
			
			<script><![CDATA[
				import com.workfusion.studio.rpa.recorder.api.*
				import com.workfusion.studio.rpa.recorder.api.types.*
				import com.workfusion.studio.rpa.recorder.api.custom.*
				import com.workfusion.studio.rpa.recorder.api.internal.representation.*
				import com.workfusion.bot.exception.*
				
			
                println "This is test One."
				def memberno = RList.of()
				def winname = RString.of('${driver().getWindowHandle()}')
				def appid = RList.of()
				def url = RString.of('https://www.google.com')
				com.workfusion.rpa.helpers.RPA.metaClass.static.$ = { Closure c -> c.call() } // Support for Expression action. Should be implemented in RPA class in next release.
				timeouts().pageLoadTimeout(15000, java.util.concurrent.TimeUnit.MILLISECONDS)
				openChrome(UrlOperations.ensureProtocol("${url}"))
				sleep(10000)
				window().maximize()
			]]></script>
			
				<var-def name="employees">
	<database connection="jdbc:sqlserver://fsdfdfdfds:1433;databaseName=xxxx;user=qaddd;password=qaddd"
		        jdbcclass="com.microsoft.sqlserver.jdbc.SQLServerDriver">
				SELECT Palphaappid, dob FROM [xxx].[dbo].[Person] WHERE APPID IN (SELECT MAX(Appid) from [xxx].[dbo].[xxxson])
			  </database>
	</var-def> 
			 <loop item="emp">
			  <list> <var name="employees"/> </list> 
			   <body> <template>
	<script><![CDATA[	
			println	"Salary of ${emp.get("Palphaappid")} is ${emp.get("dob")}"
		 ]]></script>		
	      </template> </body>
	      </loop>
	      
			<script><![CDATA[
				import com.workfusion.studio.rpa.recorder.api.*
				import com.workfusion.studio.rpa.recorder.api.types.*
				import com.workfusion.studio.rpa.recorder.api.custom.*
				import com.workfusion.studio.rpa.recorder.api.internal.representation.*

				import com.workfusion.bot.exception.*


				com.workfusion.rpa.helpers.RPA.metaClass.static.$ = { Closure c -> c.call() } // Support for Expression action. Should be implemented in RPA class in next release.



				try {
					$$(By.tagName("html"))
				} catch (Exception i0) {
					throw new IllegalStateException("Failed switch to browser. It might be closed in preceding actions.", i0)
				}



				$(byXpath("//*[@id=\"tsf\"]/div[2]/div/div[1]/div/div[1]/input")).click()



				inDesktop {
					sendKeys(StringTransformations.escapeAutoitText("test"))
				}

				sleep(3000)
			]]></script>
			
		</robot>
	</robotics-flow>
</config>

@ashapkina , thanks again. can the value stored in the variable declared for plugin be retrieved in the script section?? for example in this case be used in following script section?

Thanks,

Yes, but make sure to define the recorder variable in the script.
You can use script-var plugin.

	<script-var name="test_var">
       Hello world!
    </script-var>
			

			<script><![CDATA[
				import com.workfusion.studio.rpa.recorder.api.*
				import com.workfusion.studio.rpa.recorder.api.types.*
				import com.workfusion.studio.rpa.recorder.api.custom.*
				import com.workfusion.studio.rpa.recorder.api.internal.representation.*
				import com.workfusion.bot.exception.*

				def text = RString.of(test_var)

Great…!!
thanks.

1 Like

Hi @ashapkina, I have bot task that has command to connect to sql server and execute the query, which works perfectly fine when run as bot task from Workfusion studio, When i export the same task to Control Tower to run as business process, it fails to find the sql driver (jar) which I have configure in Workfusion Studio, it throws the error.

Step name ‘L360_bot_task’ has failed. Reason: '[urn:uuid:37F13B8B2A0775739E156477377908213] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] org.webharvest.exception.ScriptException: Config line 11: script block java.sql.SQLException: No suitable driver found for jdbc:sqlserver://NsfdfdfdADB03:1433;databaseName=LfdfdfppMaster;user=qdfder;password=qafder

Please let me know where to place the jar file to make it work in the Control Tower.

Best–
Manoj