Conditional Cell Coloring in data forms using Groovy
When it comes to highlighting certain data cells, we all must have got our hands on validation rules. Undoubtedly, they make things quite descriptive and help to control data entry when required. But at the same time, the trouble to maintain all these objects is equally troublesome.
Let’s take an example of a simple scenario,
If the data is missing, color it light yellow
If the no. of units is less than 10, color it yellow
If the no. of units is more than 10, color it light blue
If the no. of units is exactly 10, fill no color
And make the Year Total value as Grey.
If we go for validation rules for this in form/s, we must set the required conditional formatting.
How about we have Groovy scripting capability in our application and lets see how Groovy makes our life easy by just maintaining a small piece of code which can be tagged to any form to serve the same purpose.
Let’s understand different parts of the code.
The 1st line points to the grid then each data cell iterates one after another.
1st if statement checks whether the cell value is missing then assigns cell color as light yellow.
Similarly, the other 2 elseif checks the other two conditions and assigns color respectively.
To make grey color to all Year Total value, “YearTotal” is specified with the data cell Iterator. This iterates all cells within year total and assigns the color.
How To Create Groovy Script
From calculation Manager create a new rule and choose as edit script and script type as ‘Groovy script’.
Write the code and then validate and deploy the rule.
Add Rule to Form
Attach the rule to required data form. Check the ‘Run Before Load’ as BR property and Save the form.
Output
This groovy rule can have all such conditions listed together in single rule which can be attached to multiple data forms making them behave the same way. Even a more complex scenario will be easier to achieve through groovy rather than validation rule. With support for Groovy rules in Oracle EPM Enterprise Cloud, you can address all types of limitations. Groovy improves the performance by creating focused calculations. Dynamically generate calculation scripts at runtime based on contexts defined in the Groovy script. So Groovy scripting plays well with EPM and makes application work efficient and easier.
Contact informationWe are always ready to help you and answer your questions
KOLKATA
Unit No. 803 & 804, 8th Floor, Merlin Matrix, DN-10 Sector – V, Saltlake, Kolkata – 700091, ISO 27001 Certified