Error with custom script in Control Tower

hi,
I need help again, I found a lot of errors in custom script when run on the control tower, but it worked in the studio.

like this.

Step name ‘letter_print_step_03_v1’ has failed. Reason: ‘[urn:uuid:29223A19AA24D249231543309397978210]
robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410]
com.workfusion.studio.rpa.recorder.playback.PlaybackException:
Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=45,name=Optional[CustomScriptAction],
parent=-5,nextSibling=46,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction,
recorder:CustomScriptAction],name=[page],active=[true],actionDetails=[(page)],script=[@CustomScriptAction(
input = [‘tipe_surat’,‘jum_data’], output = ‘page’ )
def customScript() { def pages = RString.of(“1”);
def n = RNumber.of(2);
def cek = jum_data as RNumber
def jum_temp = RNumber.of(cek * 2)
if(tipe_surat == RString.of(‘PRO’)) {
for (n; n <= jum_temp ; n++) {
if((n%2) > 0) { pages = RString.of(pages+","+n) } } }
page = pages; }]]]’

Code :

@CustomScriptAction(
	input = ['tipe_surat','jum_data'], // jum_data get value from excel
	output = 'page'
) 

def customScript() 
{
	def pages = RString.of("1");
	def n = RNumber.of(2);
	def cek = jum_data as RNumber
	def jum_temp = RNumber.of(cek * 2)
	
	if(tipe_surat == RString.of('PRO'))
	{
		for (n; n <= jum_temp ; n++)
		{
			if((n%2) > 0)
			{
				pages = RString.of(pages+","+n)
			}
		}
	}
	
	page = pages;
}

Hi @abdu_rachman please share the whole event log to see the error details.

Thank you.

Version:1.0 StartHTML:000000277 EndHTML:001377835 StartFragment:001334466 EndFragment:001377601 StartSelection:001334466 EndSelection:001377601 SourceURL:http://localhost:15280/workfusion/secure/business-process/edit/f12fb8d9-4b82-42db-82e6-f68f9db62273?actTab=RESULTS

`org.webharvest.exception.PluginException: [urn:uuid:29223A19AA24D249231543309397978210] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=45,name=Optional[CustomScriptAction],parent=-5,nextSibling=46,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],name=[page],active=[true],actionDetails=[(page)],script=[@CustomScriptAction(
input = [‘tipe_surat’,‘jum_data’],
output = ‘page’
)

def customScript()
{
def pages = RString.of(“1”);
def n = RNumber.of(2);
def cek = jum_data as RNumber
def jum_temp = RNumber.of(cek * 2)

if(tipe_surat == RString.of('PRO'))
{
	for (n; n <= jum_temp ; n++)
	{
		if((n%2) > 0)
		{
			pages = RString.of(pages+","+n)
		}
	}
}

page = pages;

}]]]
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:128)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:116)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:171)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:142)
at com.workfusion.service.machine.BotRecordExecutionService.lambda$processSubmissionWithAllocationLogger$3(BotRecordExecutionService.java:112)
at com.workfusion.utils.thread.ThreadMonitoringUtils.executeWithAllocatedMemoryCallback(ThreadMonitoringUtils.java:17)
at com.workfusion.service.machine.BotRecordExecutionService.processSubmissionWithAllocationLogger(BotRecordExecutionService.java:112)
at com.workfusion.service.machine.BotRecordExecutionService.lambda$processRecord$0(BotRecordExecutionService.java:95)
at com.workfusion.utils.thread.NamedThreadTemplate.executeWithNamedThread(NamedThreadTemplate.java:10)
at com.workfusion.service.machine.BotRecordExecutionService.processRecord(BotRecordExecutionService.java:95)
at com.workfusion.service.machine.thread.RecordProcessThread.run(RecordProcessThread.java:28)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.webharvest.exception.PluginException: com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=45,name=Optional[CustomScriptAction],parent=-5,nextSibling=46,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],name=[page],active=[true],actionDetails=[(page)],script=[@CustomScriptAction(
input = [‘tipe_surat’,‘jum_data’],
output = ‘page’
)

def customScript()
{
def pages = RString.of(“1”);
def n = RNumber.of(2);
def cek = jum_data as RNumber
def jum_temp = RNumber.of(cek * 2)

if(tipe_surat == RString.of('PRO'))
{
	for (n; n <= jum_temp ; n++)
	{
		if((n%2) > 0)
		{
			pages = RString.of(pages+","+n)
		}
	}
}

page = pages;

}]]]
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlugin.executePlugin(RecorderPlugin.java:108)
at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:117)
… 18 more
Caused by: com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=45,name=Optional[CustomScriptAction],parent=-5,nextSibling=46,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],name=[page],active=[true],actionDetails=[(page)],script=[@CustomScriptAction(
input = [‘tipe_surat’,‘jum_data’],
output = ‘page’
)

def customScript()
{
def pages = RString.of(“1”);
def n = RNumber.of(2);
def cek = jum_data as RNumber
def jum_temp = RNumber.of(cek * 2)

if(tipe_surat == RString.of('PRO'))
{
	for (n; n <= jum_temp ; n++)
	{
		if((n%2) > 0)
		{
			pages = RString.of(pages+","+n)
		}
	}
}

page = pages;

}]]]
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:54)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:64)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlaybackProcess.start(RecorderPlaybackProcess.java:89)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlugin.play(RecorderPlugin.java:132)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlugin.executePlugin(RecorderPlugin.java:103)
… 23 more
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: CustomScript_customScript(com.workfusion.studio.rpa.recorder.api.types.RString, com.workfusion.studio.rpa.recorder.api.types.RString, com.workfusion.studio.rpa.recorder.api.types.RString)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1752)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1559)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:237)
at Script12_genScript_1406.run(Script12_genScript_1406.groovy)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:48)
at com.workfusion.studio.rpa.recorder.playback.player.PlaybackContext.executeScript(PlaybackContext.java:65)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.executeBehavior(TemplateAction.java:33)
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:46)
… 29 more`

it is the same issue we previously had. If you have several custom actions in the business process, you need to name the methods differently.

Owhhh,

sorry I didn’t read until it was finished.

Thankyou

1 Like

@abdu_rachman that’s ok :slightly_smiling_face:
we’ll try to fix this issue with custom actions on Control tower as soon as we can.