How to get next month date if the last day of month is either 29,30 or 31

Yes, it should have the name of your script.
In my example above it is written with e.

I dont know why the Exported BOt Task is showing date as 18th Oct 2019

Below are the changes made in the BOT Task.

<?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.*


				def path = RString.of('C:\\Karan-My Files\\Automation\\SL Report Generation\\Files\\CountrywiseSLReport')


				def month = RString.of('')


				def foldercontent = RList.of()


				def date3 = RString.of('')


				def date2 = RDateTime.fromCanonical('2019-10-18T09:32:47+08:00[Asia/Singapore]')


				def date1 = RDateTime.fromCanonical('2019-10-18T09:32:42+08:00[Asia/Singapore]')



				enableTypeOnScreen()


				date1 = RDateTime.now()


				@CustomScriptAction(
				input = ['date1'],
				output = 'date2'
				)
				def anatoly() {
					date2 = date1.plus(java.time.Period.ofDays(2))
				}
				
customScriptActionCall_anatoly: {}

				date3 = RString.of(date2.toRepresentation("MMM dd yyy;en-SG;" + java.time.ZoneId.systemDefault()))



				openAndFocus("notepad.exe", 5000, 300)




				inDesktop {

					sendKeys(StringTransformations.escapeAutoitText(date3.toString()))
				}




				putAt("path", path)
				putAt("foldercontent", foldercontent)
				putAt("date3", date3)
				putAt("month", month)
				putAt("date2", date2)
				putAt("date1", date1)
			]]></script>
		</robot>
	</robotics-flow>

	<export include-original-data="true">
		<single-column name="path"
			value="${path.toCanonicalRepresentation()}" />
		<single-column name="foldercontent" value="${foldercontent.toString()}" />
		<single-column name="date3"
			value="${date3.toCanonicalRepresentation()}" />
		<single-column name="month"
			value="${month.toCanonicalRepresentation()}" />
		<single-column name="date2"
			value="${date2.toCanonicalRepresentation()}" />
		<single-column name="date1"
			value="${date1.toCanonicalRepresentation()}" />
	</export>


</config>
1 Like

Looks like there is an error in the method: it says scrip instead of script

so you will need to use customScripActionCall

The whole bot task will be:

<?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.*

				def path = RString.of('C:\\Karan-My Files\\Automation\\SL Report Generation\\Files\\CountrywiseSLReport')
				def month = RString.of('')
				def foldercontent = RList.of()
				def date3 = RString.of('')
				def date2 = RDateTime.fromCanonical('2019-10-18T09:32:47+08:00[Asia/Singapore]')
				def date1 = RDateTime.fromCanonical('2019-10-18T09:32:42+08:00[Asia/Singapore]')

				enableTypeOnScreen()


				date1 = RDateTime.now()


				@CustomScriptAction(
				input = ['date1'],
				output = 'date2'
				)
				def anatoly() {
					date2 = date1.plus(java.time.Period.ofDays(2))
				}
				
				customScripActionCall_anatoly: {}

				date3 = RString.of(date2.toRepresentation("MMM dd yyy;en-SG;" + java.time.ZoneId.systemDefault()))

				openAndFocus("notepad.exe", 5000, 300)

				inDesktop {

					sendKeys(StringTransformations.escapeAutoitText(date3.toString()))
				}

				putAt("path", path)
				putAt("foldercontent", foldercontent)
				putAt("date3", date3)
				putAt("month", month)
				putAt("date2", date2)
				putAt("date1", date1)
			]]></script>
		</robot>
	</robotics-flow>

	<export include-original-data="true">
		<single-column name="path"
			value="${path.toCanonicalRepresentation()}" />
		<single-column name="foldercontent" value="${foldercontent.toString()}" />
		<single-column name="date3"
			value="${date3.toCanonicalRepresentation()}" />
		<single-column name="month"
			value="${month.toCanonicalRepresentation()}" />
		<single-column name="date2"
			value="${date2.toCanonicalRepresentation()}" />
		<single-column name="date1"
			value="${date1.toCanonicalRepresentation()}" />
	</export>


</config>

Negative , copied and run the same code shared by you in BOT Task.

The Date is not incrementing.

@Anatoly can you share the .xml file of the bot task here?

Hi , good morning , please refer below .xml code.

<?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.*


				def path = RString.of('C:\\Karan-My Files\\Automation\\SL Report Generation\\Files\\CountrywiseSLReport')


				def month = RString.of('')


				def foldercontent = RList.of()


				def date3 = RString.of('')


				def date2 = RDateTime.fromCanonical('2019-10-18T09:32:47+08:00[Asia/Singapore]')


				def date1 = RDateTime.fromCanonical('2019-10-18T09:32:42+08:00[Asia/Singapore]')



				enableTypeOnScreen()


				date1 = RDateTime.now()


				date2 = RDateTime.now()



				@CustomScriptAction(
				input = ['date1'],
				output = 'date2'
				)
				def anatoly() {
					date2 = date1.minus(java.time.Duration.ofDays(1))
				}
                customScriptActionCall_anatoly: {}
				date3 = RString.of(date2.toRepresentation("MMM-yyyy-dd;en-SG;" + java.time.ZoneId.systemDefault()))



				openAndFocus("notepad.exe", 5000, 300)




				inDesktop {
					sendKeys(StringTransformations.escapeAutoitText("${date3}"))
				}




				putAt("path", path)
				putAt("foldercontent", foldercontent)
				putAt("date3", date3)
				putAt("month", month)
				putAt("date2", date2)
				putAt("date1", date1)
			]]></script>
		</robot>
	</robotics-flow>

	<export include-original-data="true">
		<single-column name="path"
			value="${path.toCanonicalRepresentation()}" />
		<single-column name="foldercontent" value="${foldercontent.toString()}" />
		<single-column name="date3"
			value="${date3.toCanonicalRepresentation()}" />
		<single-column name="month"
			value="${month.toCanonicalRepresentation()}" />
		<single-column name="date2"
			value="${date2.toCanonicalRepresentation()}" />
		<single-column name="date1"
			value="${date1.toCanonicalRepresentation()}" />
	</export>


</config>

There is no line customScripActionCall_anatoly: {} so your custom script is not executed.

There must have been a bug in the version of the software you use and it is not added automatically, so you need to either run this script from Recorder, or add this line of code manually after exporting it to bot task.

I am manually adding the customScriptActionCall_anatoly: {} to the BOT Task , seems to be some bug.

Change it to customScripActionCall_anatoly: {}

Thanks for your support , i think some issue is there in my current version.

I will download the new version.

thanks alot.

1 Like