Custom action suddenly stopped working after update?

Hi,

I have been using a custom action in order to compare dates pulled from an excel sheet in order to figure out if they have missed their deadline. I were using groovy java extensions, specifically clearTime() and Date.parse(). It still works in the code view, but when i run the custom action in the recorder get an error message: Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.GregorianCalendar.clearTime() is applicable for argument types: () values: []

If i remove all instances of clearTime i still get this message: Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.Date.parse() is applicable for argument types: (String, String) values: [dd.MM.yyyy, 22.01.2018]

I find it strange that this works in code view but not in the recorder, especially since it used to work before, i think it stopped working after updating workfusion (but i am not completely certain, as i am working on other projects in parallel).

Any input would be appreciated, i would at least like to know if i am doing something wrong or if something broke at some point out of my control :stuck_out_tongue:

Here is the full error message with the code:

@CustomScriptAction(
    input = ['master_table'],
    output = 'result_table'
    )

    def customScript() {
	def myTimezone = java.time.ZoneId.systemDefault()
	Date working_date = new Date()
	def diff = 0
	def c_then = Calendar.getInstance()
	def c_now = Calendar.getInstance()
	def my_table = master_table
	c_now.clearTime()				
					
	for (int i = 2; i != my_table.getNumberOfRows()+1; i++) {
		def row_list = my_table.getRow(i)
		working_date = new Date().parse("dd.MM.yyyy", row_list.getAt(9) as String)
		c_then = working_date.toCalendar()
		c_then.clearTime()
							
		if (row_list.getAt(18).toString().equals('0') || row_list.getAt(18).toString().equals('1')){
			diff = c_now.minus(c_then)
			if (diff > 14) {
				my_table.put(i, 18, '2')
				my_table.put(i, 19, 'Klar for purrevarsel SMS')
			}
			else {
				my_table.put(i , 18, '1')
				my_table.put(i, 19, 'purring ikke forfalt')
			}								
		}
						
		if (row_list.getAt(18).toString().equals('3')){
			diff = c_now.minus(c_then)
			if (diff > 14) {
				my_table.put(i, 18, '4')
				my_table.put(i, 19, 'Klar for stengevarsel SMS')
			}								
		}
						
		if (row_list.getAt(18).toString().equals('5')){
			diff = c_now.minus(c_then)
			if (diff > 14) {
				my_table.put(i, 18, '6')
				my_table.put(i, 19, 'Klar for stenge SMS')
			}								
		}
	}
	result_table = my_table				
    }

Error executing CustomScriptAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=3,name=Optional[CustomScriptAction],parent=-1,nextSibling=4,arguments=ActionArguments[delay=[0],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],pollingInterval=[300],active=[true],script=[
],awaitTimeout=[5000]]]
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.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.GregorianCalendar.clearTime() is applicable for argument types: () values: []
Possible solutions: clear(), getTime(), clear(int), setTime(java.util.Date)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at CustomScript_customScript.customScript(Script5.groovy:22)
at CustomScript_customScript$customScript.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script5.run(Script5.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)
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.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)

Hello @nicklas.
Could you please advise from which version to which did you update?

I updated to version 2.2.0.1015 from 2.1.2.816 i think, looking at the installers.

Thank you, Nicklas. Seems that this is related to this method clearTime(). Could you please try to Use set(Calendar.HOUR_OF_DAY, 0) instead of it?

Thanks, that works in this instance, but the Date.parse() still does not work. I also tried to format the calendar instance to a string with calendar.format() (another groovy method) and that also does not work. Seems to me that i cant access the groovy JDK┬┤s extensions to the Java JDK in the recorder for some reason, or at least the date and calendar portion of it.

I can probably work around most of these issues using different classes and methods for now, but it will be incredibly annoying and time consuming in the long run now that i have gotten used to groovy :confused: