E9.2 P0912 Update GL date

Jetski60

Member
Hi,
I'm trying to do an Orchestration to update specific Standing Journals GL Date to 20th of the future month while keeping all other standing Journals as Last day of the future month.

new to orchestration,
I managed to do a form request and run it with GL date static to 20th of October but can't figure how to make it set to 20th of future month every time it runs.


Thanks
 

Attachments

  • Orch.jpg
    Orch.jpg
    10.5 KB · Views: 4
  • GL date.jpg
    GL date.jpg
    110.6 KB · Views: 5
Last edited:
You will need a step preceding this to calculate the 20th of the future month. If you have logic extensions and experience with Event Rules, you might be able to "more easily" do it using date functions, otherwise you're looking at a scripting step with a bit more nuance.

Be very choosy about where you set defaults within form requests! Unless they're absolutely necessary in there, move defaults outward to the transformations dialog. Defaults in form requests have ended up burning me on big data conversions in the past.
 
Hi,
I'm trying to do an Orchestration to update specific Standing Journals GL Date to 20th of the future month while keeping all other standing Journals as Last day of the future month.

new to orchestration,
I managed to do a form request and run it with GL date static to 20th of October but can't figure how to make it set to 20th of future month every time it runs.


Thanks
As @DaveWagoner suggested, you will need a step to calculate the date and pass it in to the form request. Attached is how you might do it in JRuby in a Custom Request. This will always give you the 20th of the following month. 2023-10-12_09-55-01.png
 
chatGPT is your friend for writing you very good groovy scripts :)

Stay within the template provided you when you first start a groovy script component, but then you should be able to copy paste code from chatGPT and either have it work, or go back and forth sharing the errors. It's been very good for me and has shaved hours off of my workflow usually spent googling around.
 
I did end up using ChatGPT after spending like 4 hours on google, going through tutorial...etc.

I settled on this one, but
import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
import groovy.json.JsonSlurper;

HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

// Get the current date
def currentDate = new Date()

// Get the current month
def currentMonth = currentDate.month

// Calculate the next month
def nextMonth = (currentMonth + 1) % 12

// Calculate the year
def year = (currentMonth == 12) ? currentDate.year + 1 : currentDate.year

// Create a new date with the 20th of the next month
def updatedDate = new Date(year - 1900, nextMonth, 20)

// Print the dates
println "Current Date: ${currentDate}"
println "Updated Date: ${updatedDate}"
return returnMap;
}
1) how to test it that it's correct and accurate? I know there is test button in orchestrator for this, but I lack the how to
 
so far,
1) orchestration completed without an error 1697410695982.png
2) custom Request, has the groovy script for setting date and updated date
import com.oracle.e1.common.OrchestrationAttributes;
import java.text.SimpleDateFormat;
import groovy.json.JsonSlurper;

HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
HashMap<String, Object> returnMap = new HashMap<String, Object>();

def currentDate = new Date()
def calendar = Calendar.getInstance()
calendar.time = currentDate

// Add one month
calendar.add(Calendar.MONTH, 1)

// Set the day to 20th
calendar.set(Calendar.DAY_OF_MONTH, 20)

def updatedDate = calendar.time

def dateformat = new SimpleDateFormat("dd/MM/yyyy")

println "Current Date: ${dateformat.format(currentDate)}"
println "Updated Date: ${dateformat.format(updatedDate)}"


return returnMap;
}

3)Form Request, has the specific three documents that I want to the change date future month on 20th of the month
A) 1697410854429.png
B) 1697410892515.png
and it repeats for the other two documents, I know this is not the best way and i need to do Transformation inputs for these documents possibly from a CSV file or something, and that is not my main issue, issue is that G_LDate if put in like 20/11/2023 " dd/mm/yyyy" NZ date format, it works perfectly. but when running it like this nothing gets updated, I'm missing something but can't point it where
 
The problem is that you are not returning the new GL Date to the orchestration. Replace the following lines:

println "Current Date: ${dateformat.format(currentDate)}"
println "Updated Date: ${dateformat.format(updatedDate)}"

with:

returnMap.put(“Current Date”,dateformat.format(currentDate))
returnMap.put(“Updated Date”,dateformat.format(updatedDate))

Then click the Load Outputs button. When you save the Custom Request you should see Current Date and Updated Date in the outputs section at the bottom of your screen. You can then click the test button in the custom service request to see the result of your code.

Once you are happy that it works, you will need to map updatedDate to G_L_Date in the orchestration transformation.
 
Thank you @Kevin Long, your suggestions appear to be working.
I'm learning groovy just like in last 48 hours, so your help much appreciated and i didn't know about returnMap or put.
need to promote to PY ,UAT environments.

Thanks
 
Back
Top