Custom Script Action Fails in Control Tower (v2.0.1)

Hi,
I created a recording that uses 3 Custom Script Actions.
The fist and the third in execution order are the same and have the following variables
@CustomScriptAction(
input = [‘my_timezone’],
output = ‘temp_date’
)

The second one has the
@CustomScriptAction(
input = [‘log_file’,‘input_dbcon_pomp_pom_owner’,‘input_qfile_pomp’],
output = ‘results_table’
)

When running from Workfusion Studio (Recorder) everything works fine.
The first time executed in Control Tower also everything is fine.Next executions fail with the following error:

at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:116)
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:187)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:97)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:168)
at com.workfusion.service.machine.BotRecordExecutionService.process(BotRecordExecutionService.java:139)
at com.workfusion.service.machine.BotRecordExecutionService.processSubmissionWithAllocationLogger(BotRecordExecutionService.java:118)
at com.workfusion.service.machine.BotRecordExecutionService.lambda$processRecord$0(BotRecordExecutionService.java:97)
at com.workfusion.utils.thread.NamedThreadTemplate.executeWithNamedThread(NamedThreadTemplate.java:10)
at com.workfusion.service.machine.BotRecordExecutionService.processRecord(BotRecordExecutionService.java:97)
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=54,name=Optional[CustomScriptAction],parent=11,nextSibling=55,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],name=[Check_OPS_Database_for_errors],active=[true],actionDetails=[(Check_OPS_Database_for_errors)],script=[@CustomScriptAction(
input = [‘log_file’,‘input_dbcon_pomp_pom_owner’,‘input_qfile_pomp’],
output = ‘results_table_str’
)



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:30)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:17)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlaybackProcess.start(RecorderPlaybackProcess.java:79)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlugin.play(RecorderPlugin.java:123)
at com.freedomoss.crowdcontrol.webharvest.plugin.recorder.RecorderPlugin.executePlugin(RecorderPlugin.java:104)
… 21 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, com.workfusion.studio.rpa.recorder.api.types.RString)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1732)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1532)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:232)
at Script13_genScript_3545.run(Script13_genScript_3545.groovy)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:90)
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:35)
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:46)
… 27 more

1 Like

Hi @adimitriou, do I understand correctly that you have these actions in a loop. and in the first loop everything works fine, but in the second one they fail?

No are not in a loop, they are sequential and executed once.
The recorder will execute them one after the other and correct all the times tested.
But in control tower the first execution of the BP (has only this recording) after publishing the execution, is correct.
The next executions (is scheduled every 20 minutes) will fail.

The problem seems to be that the definition of CustomScriptAction has different number of variables, because if I leave the 2 Custom Actions that are the same (1st and 3rd) is works fine.

I tried the same in version V2.0.2 and it behaves the same way.

@ashapkina Is it possible to change the name of the CustomScriptAction and customScript or those are expected always with those names? I couldn’t find any info

@adimitriou could you share the recording with us? we’ll try to reproduce it.
If it has sensitive data and you cannot post it on the forum, you can send it to me via a personal message.

I created a simple recording just for testing and sharing.
The type of variables(input/output) doesn’t affect it (did some tests), only the number.

custom_script_issue.zip (21.5 KB)

1 Like

Hi,
did you test it?

I did and got the same error. Our development team is now investigating.

:grinning: Right, sorry

Hi @adimitriou,

We have found what causes the issue. We are planning to fix it in the future and improve Custom Actions (it is still an experimental feature).

For now, please try this workaround:

If you have more than 1 custom action in the recording, for each action you need to define a different method (CustomScriptAction1 in the example below):

@CustomScriptAction(
   input = ['my_timezone'],    
   output = 'resdate'
)

def CustomScriptAction1() {

def now = new Date()
resdate=RDateTime.fromRepresentation(now.format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("${my_timezone}")), "yyyy-MM-dd HH:mm:ss;en-US;${my_timezone}")

}

The name of the class has to start with a letter.

Let me know if it helps.

4 Likes

Thank you, I confirmed the solution,but I have some questions.
If I understand well I can use any name for the CustomScriptAction1() method and the only constrain is to start with a letter. i.e. test_method() is a valid name correct?
If yes, can you add this notice to documentation?

Also, I checked and it’s possible to use code in a groovy method without the proposed @CustomScriptAction, and in that case you can access all Recording variables and also update them without limiting the output to one. Can I use that or you are planning to change it?
i.e. the above will become

def CustomScriptAction1() {

def now = new Date()
resdate=RDateTime.fromRepresentation(now.format(“yyyy-MM-dd HH:mm:ss”, TimeZone.getTimeZone("${my_timezone}")), “yyyy-MM-dd HH:mm:ss;en-US;${my_timezone}”)
}

CustomScriptAction1()

1 Like

Yes, the name test_method() will be valid.

You can use that, but it will work differently. All variables you use will be updated after the execution, while in custom action, only the output variable is updated.

So, CustomScriptAction is the suggested way to use it mainly for better performance correct?

And better control over the recordings variables you use.

However, as I wrote, we might change the CustomAction feature in the future.

Hi @ashapkina,

I have the same issue but after changing the method. still the same error

@rodel.sarate can you share your recording and the full text of the error message you get?