Oracle EPM Planning: - Validating RTP (Run Time Prompts) Using Groovy
When building applications in
PBCS, there are many situations where users need to provide information using
some prompt. While this is particularly valuable in Oracle EPM Planning
applications for modules like capex planning, workforce planning or project
planning, it can be used across many other use cases as well. With Groovy,
input validation becomes much more powerful. We can compare user inputs, apply
restrictions, and even prevent a calculation from running until all required
inputs are validated. The key advantage is that prompts can remain open,
requiring users to either enter valid data or cancel the request, ensuring that
only accurate information is submitted.
Validating Start Date / End Date Use Case
I
was working with a client and while discussing with them about the data form
structure they asked one of the requirements to validate the start and end date
of the Project. E.g. when on a right click they add a project they also must
provide the start and end date of the project, but they wanted to make sure
that system must throw an error if the start date is greater than the end date.
We agreed to provide them the option, but we wanted to make sure data is also
not stored in the system to avoid any confusion, so we thought to try the
groovy script.
Some
of you might think, we can do use the @Return function in calc manager and call
the error but this need data to be stored first so we are looking for an
optimized way and wanted to use the groovy script. The purpose now is to
have the ability to keep the prompts open, and force the user to either enter
valid data, or cancel the request.
Below
screen should tell you the expectation where user wanted to add a project but
start date and end date condition must validate first.
When
a user enters an end date prior to a start date and launches the rule, it should
throw an error and the RTP window doesn’t go away. At this point, the
user must correct the error or cancel the execution of the business rule.
Groovy Script to be used
Below
rule is an example and can be updated modified as per the business need:
/*RTPS:
{RTP_StartDate} {RTP_EndDate}*/
def
mbUs = messageBundle(["validation.InvalidDate":" The End date
must be after the start date."])
def
mbl = messageBundleLoader(["en" : mbUs])
//
Validate the Rtp values
if(rtps.RTP_StartDate.getEssbaseValue()
> rtps.RTP_EndDate.getEssbaseValue())
throwVetoException(mbl,
"validation.InvalidDate", rtps.RTP_StartDate)
//
Print the results to the log
println
"Start Date: " + rtps.RTP_StartDate.getEssbaseValue()
println
"End Date: " + rtps.RTP_EndDate.getEssbaseValue()
RTP (Run Time Prompt)
If you are
not aware about creating RTPs in Groovy - https://docs.oracle.com/en/cloud/saas/enterprise-performance-management-common/ecalc/cmgr_enter_rtp_values.html
This oracle
document will cover the same. If you haven’t read that, it would be a
good time to take a look, as it explains the basic of this object. In
this simple example, we just want to make sure the term date is greater than
the hire date.
messageBundle
The
first thing that is requires is to create a messageBundle and
messageBundleLoader. These two objects work together to hold the errors,
the error messages. The messageBundle is a map that holds all the errors (name
and description). In this example, we only have one error, but more can
be added and separated by commas. The messageBundleLoader holds all the
messageBundle objects that represent the different languages.
throwVetoException
When an
exception is found, executing this method will initiate an error and cause the
RTP validations to fail. This method requires the messageBundleLoader,
and the error to be returned to the user.
Other Use
Cases
By now you
are probably already thinking of other uses of this. I can see limiting
growth rates, confirming purchase date and in-service date for an asset, hire
and end date of employees and so on.
Conclusion
Being
able to validate user input prior to executing a calculation and returning the
input request to the user is a huge step forward, and just another benefit
of Groovy calculations. We can reduce the number of user errors and
improve the user experience.
Comments
Post a Comment