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

Hi Every one.

We have a requirement where BOT needs to generate the 1st date of next month provided the current date is 29th,30th or 31st.

Example - If the current date is 30th nov then the result should be 1st Dec.

Please note we are using the older version of RPA , where the custom scripts doesn’t work in the BOT Task.

Would be great if any one can make action flows for me.

Regards,
Anatoly.

Kindly help.

Hi @Anatoly what version of RPA Express do you use?

Hi ,

We are using older version of Workfusion , due to some infra issue we are unable to download any new updates of external applications at the moment.

Version 2.0-beta
WorkFusion RPA Express
Sunbird

Custom Actions were introduced in version 1.3.0, so you can use it to get the next day
https://kb.workfusion.com/display/RPAe/Code+Samples#CodeSamples-ModifyingtimeperiodYellowWorkFusion

Hi ,

Thank you for the response.

Unfortunately when the code is exported to the bot task it will display only today’s date.

BUT when the CODE/Script is executed in the below window then it will display the desired result.
image

Can you share the custom script you used and the screenshot of the variables panel?

Screen 1-> IF i run the BOT here in this screen , then the output is 26

If i Export the same Task to BOT Task then the output is 27th which is incorrect.

@Anatoly please share the code of the exported bot task.

Thank you.

Please refer below 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()


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


				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>

Code Shared.

For some reason, the code is missing the line
customScripActionCall_customeScript: {}
that executes the custom script.

So it is not executed.

It needs to go in the code right after the script

Seems so , anything i am missing ?

I’m not sure I understand your question.

Does the code work correctly when you add this line?
customScripActionCall_customeScript: {}

I have added this customScripActionCall_customeScript: {}

In the worflow window the output is coming correct , But as i export this to bot task the output is coming as 18th oct.

The Expected out put is 4th dec

The below is the bot task.

<?xml version="1.0" encoding="UTF-8"?>
<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()


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


			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>
1 Like

You don’t need to add in the custom script.

You need to add in the bot task, after you export your recording. Your code should look like this.

<?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 customeScript() {
					date2 = date1.plus(java.time.Period.ofDays(2))
				}
// the above line of code goes here, right after the custom action
customScripActionCall_customeScript: {}

				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>

Noted , let me try the above code and update you…

Many Thanks

Same Date it is giving 18th Oct even after exporting to the BOT Task.

two Diff Dates are coming

Workflow Windows -> 04 Dec 2019 ( Which is correct )
Bot Task -> 18 Oct 2019 ( Incorrect )

customScripActionCall_customeScript: {}

E is added with Custom

Isnt it -> customScripActionCall_customScript: {}